Amazing!. Couldn't be more than 10 mins since I posted and 3 replies!.
Thanks very much....
In that time, before I saw these posts, I came up with the following
def foo(p)
p.call(100)
end
a = Proc.new {|b| puts b}
foo(a)
but now I see that presumably proc (in lowercase) is presumably a
static class method and will work equally well.
i.e as you say
a = proc {|b| puts b}
Oddly, there is an inconsistency here
q = String("abc")
q = String.new("abc")
are both legal but
q = string("abc")
is not, which you would extrapolate by extension from the Proc/proc
analogy. (because
a=Proc {....}
is not legal.
In fact, perusing the documentation, I can't see how I would have
figured out the alternative mechanism using proc in lowercase - where
is this documented?
why I am keen to understand this is because languages like Perl are
infuriating because things like filehandles have special 'magic'
properties which get lost if you, for example, try to store them in a
hash, etc. This sort of thing destroys the illusion of completeness
that a truly great scripting language must provide, IMHO.
I see some hints of LISP here, too, with lambda!. A wonderful brew of
language features!