--Apple-Mail-10--405534925
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset-ASCII;
	formatðïwed


On Dec 15, 2005, at 11:57 AM, ajmayo / my-deja.com wrote:

> Also, I presume Ruby is a forward-referencing language only, unlike
> Javascript, where I can declare a function after code which calls it.
> Ruby didn't seem to like that much.

How did you run into problems with this?

irb(main):024:0> def a(x)
irb(main):025:1>     g(x)
irb(main):026:1> end
nil
irb(main):027:0> def g(x)
irb(main):028:1>    puts x
irb(main):029:1> end
nil
irb(main):030:0> a(5)
5
nil

As regards your other question

def bar(z)
     puts z
end

a  ambda { |x| puts x }

bar(a)



Alternatively to pass a block to a function without yield...

def bar(&block)
        block.call
end

bar { puts "hi!" } #prints hi


--Apple-Mail-10--405534925--