Created
August 27, 2013 01:13
-
-
Save jendiamond/6348607 to your computer and use it in GitHub Desktop.
Exercise 8 - Learn Ruby the Hard Way
This file contains hidden or 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
# the variable formatter is being assigned a series of 4 string formatters | |
# that will take 4 arguments | |
formatter = "%s %s %s %s" | |
# the method puts prints the variable formatter; using string | |
# interpolation it prints the arguments of integers that follow | |
puts formatter % [1,2,3,4] | |
# the method puts prints the variable formatter; using string | |
# interpolation it prints the arguments of 4 strings that follow | |
puts formatter % ["one","two","three","four"] | |
# the method puts prints the variable formatter; using string | |
# interpolation it prints the arguments of 4 boolean values that follow | |
puts formatter % [true, false, false, true] | |
# the method puts prints the variable formatter; using string | |
# interpolation it prints the arguments of 4 variables of itself | |
puts formatter % [formatter, formatter, formatter, formatter] | |
# the method puts prints the variable formatter; using string | |
# interpolation it prints the arguments of 4 strings that follow | |
puts formatter % [ | |
"I had this thing.", | |
"That you could type up right.", | |
"But it didn't sing.", | |
"So I said goodnight." | |
] | |
# the method puts prints the variable formatter; using string | |
# interpolation it prints the arguments of itsel, a boolean value, | |
# a strings and an integer that follow | |
puts formatter % [ formatter, true, "But it didn't sing.", 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment