# Understanding why

**URL:** <https://metaruby.com/t/understanding-why/1374>\
**Category:** Ruby Questions\
**Tags:** ruby\
**Created:** [November 23, 2017, 7:48am UTC](https://metaruby.com/t/understanding-why/1374 "2017-11-23T07:48:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![castasam123](https://metaruby.com/letter_avatar_proxy/v4/letter/c/ce73a5/32.png) [@castasam123](https://metaruby.com/u/castasam123)\
**Post date:** [November 23, 2017, 7:48am UTC](https://metaruby.com/t/understanding-why/1374/1 "2017-11-23T07:48:14Z")

</div>

In learning ruby the hard way, i am on exercise 6, and in some of the lines he puts

puts x  
puts y

puts “I said: #{x}.”  
puts “I also said: ‘#{y}’.”

and when i input that to atom and open the file in powershell, it will say puts “i said: #{x}.”  
but i am trying to understand why i would put puts x or puts y before the actual line i am printing.

---

<div class="post-metadata">

**Author:** ![danielpclark](https://metaruby.com/user_avatar/metaruby.com/danielpclark/32/823_2.png) [@danielpclark](https://metaruby.com/u/danielpclark)\
**Post date:** [November 23, 2017, 11:16am UTC](https://metaruby.com/t/understanding-why/1374/2 "2017-11-23T11:16:54Z")

</div>

The string interpolation characters `#{}` will print what ever value into the string so

```ruby
x = 4
puts "I said #{x}"

```

becomes `I said 4`. String interpolation simply allows some Ruby’s output to be placed in a string. For example:

```ruby
puts "2 + 2 is #{2 + 2}"

```

Will give us `2 + 2 is 4`

A normal `puts x` would just put the value `4` out from what `x` had stored in it and that is all. We don’t see any explanation text, just a value printed.
