I'm trying to pick up ruby and I'm impressed by all the cool stuff it
does out of the box. I'm reading a few books but i'm finding why's
poignant guide to ruby to be the most helpful and entertaining
(http://poignantguide.net/ruby).
However, I'm a bit stuck understanding how block arguments work. in his
example:
kitty_toys = [
{:shape => 'sock', :fabric => 'cashmere'},
{:shape => 'mouse', :fabric => 'calico'},
{:shape => 'eggroll', :fabric => 'chenille'}
]
kitty_toys.sort_by { |toy| toy[:shape] }.each do |toy|
puts "Blixy has a #{ toy[:shape] } made of #{ toy[:fabric] }"
end
I know what it does. I put it through irb and it works. But i don't
understand HOW it works, exactly. Mainly, the toy bit. I don't quite get
what role it plays in the code and how the code uses it.
I've read up online and in both books I have, but, for whatever reason i
STILL cannot grasp block arguments and what role they play.
Maybe I'm just brain farting here, but if anyone could lend some tips on
this I'd appreciate it.
--
Posted via http://www.ruby-forum.com/.