Created
September 23, 2018 12:28
-
-
Save harrisonmalone/e41010deba93e3a9920335d9969f5043 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
# the main difference between `.each` and `.map` | |
# they both iterate through a block but if you want to store an edited array or hash you need to use map | |
# if you simply want to display text by using `puts` on the block arguments then `each` is more useful | |
furniture = [ | |
{"name" => "bed", "color" => "black", "size" => "12", "date_created" => "12/6", "condition" => "New"}, | |
{"name" => "chair", "color" => "brown", "size" => "7", "date_created" => "6/13", "condition" => "Used"}, | |
{"name" => "desk", "color" => "maple", "size" => "9", "date_created" => "2/13", "condition" => "New"} | |
] | |
x = furniture.map do |x| | |
x.values | |
end | |
p x | |
x = furniture.each do |x| | |
p x.values | |
end | |
p x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment