December 2014
Beginner
336 pages
7h 41m
English
I will now show you how to create a format string, but rather than using variables, we’ll use values by their names. Some of this is a bit more advanced, but don’t worry you’ll learn what all of these mean later. Just type this in, make it work, and write a comment above each line translating it to English.
ex8.rb
1 formatter = "%{first} %{second} %{third} %{fourth}" 2 3 puts formatter % {first: 1, second: 2, third: 3, fourth: 4} 4 puts formatter % {first: "one", second: "two", third: "three", 5 fourth: "four"} 6 puts formatter % {first: true, second: false, third: true, fourth: false} 7 puts formatter % {first: formatter, second: formatter, ...
Read now
Unlock full access