On Thu, Oct 7, 2010 at 2:01 PM, Kaye Ng [email protected] wrote:
“code blocks may accept none, one, or more parameters”
I understand how ONE parameter is passed using the ‘each’ method.
I also understand how TWO parameters is passed, like in this code
x = { “a” => 100, “b” => 20 }
x.delete_if { |key, value| value < 25 }
p x
Can anyone give me a very simple and executable code where:
NO parameters is passed, and
irb(main):001:0> [0,1,2,3].each { puts “no param” }
no param
no param
no param
no param
=> [0, 1, 2, 3]
THREE parameters is passed
irb(main):002:0> [ [ 1,2,3 ] ].each { |i,j,k| puts i+j+k }
6
=> [[1, 2, 3]]
Ruby version is 1.9.1
SIMPLE CODE/SYNTAX ONLY PLEASE, BEGINNER HERE. =D
Was this simple enough? 
–
Phillip G.
Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.