-
-
Save hannesfostie/3075c51c6f9cb0af268e to your computer and use it in GitHub Desktop.
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
#This is an Array object loop | |
stooges = ['Larry', 'Curly', 'Moe'] | |
stooges.each { |stooge| print stooge + "\n" } | |
# using puts automatically adds a newline here, if I remember correctly. Give it a go | |
#This is Hash object loop | |
# No, it isn't :-) | |
# your variables should probably not start with a capitalized letter | |
One = "This is one" | |
Two = "This is two" | |
# this line ends in a single quote | |
Three = "This is three' | |
# this is just an array | |
someThing = [One, Two, Three] | |
# this is a hash | |
some_thing = { one: 'first stooge', two: 'second stooge', three: 'third stooge' } | |
# forgot a "do" here I believe, as well as "end": | |
some_thing.each do |key, value| | |
puts "Stooge number #{key} is the #{value}" | |
end | |
someThing.each |n1, n2, n3| | |
puts n1 + '\t' + n2 + '\t' + n3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment