-
-
Save anonymous/7071735bf5b8e29bcbd1 to your computer and use it in GitHub Desktop.
finally :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
odds = [1,3,5,7,9] | |
odds.each do |x| | |
x *= 2 | |
print "#{x}" | |
end |
However, if you:
odds.each{ |x| print "x*2" }
then you are going to see the output:
x*2x*2x*2x*2x*2x*2x*2x*2
because you are asking it to print a string, a literal value, NOT the result of looking up the variable x
and multiplying it by 2.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also: