3 ms·
Some of your questions are wrong: irb(main):001:0> data = [1,2] => [1, 2] irb(main):002:0> total = 10 => 10 irb(main):003:0> data.each { |x
by hackerboos 12y ago
Some of your questions are wrong:
irb(main):001:0> data = [1,2]
=> [1, 2]
irb(main):002:0> total = 10
=> 10
irb(main):003:0> data.each { |x| total += x }
=> [1, 2]
irb(main):004:0> puts total
13
=> nil
===
What is proper syntax for a block?
A. { |x| puts x }
B. do |x| puts x end
C. ->(x) { puts x}
D. A & B
E. B & C
F. A & C
I answered A & B which your quiz says is wrong.
You might want to read this and rewrite your quiz...
http://awaxman11.github.io/blog/2013/08/05/what-is-the-difference-between-a-block/ http://awaxman11.github.io/blog/2013/08/05/what-is-the-diffe...