Tom Schutzer-Weissmann
2005-Aug-12 15:43 UTC
[Ruby] get a reference to a function or method, not call it with no arguments
A very simple ruby question: irb(main):004:0> test_for_blockdev = FileTest.blockdev? ArgumentError: wrong number of arguments (0 for 1) from (irb):4:in `blockdev?'' from (irb):4 irb(main):005:0> I don''t want to call the damn thing, I just want a reference to it! Or has too much javascript clouded my brain to the way of ruby? Tom Sw ___________________________________________________________ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
Matthew Beale
2005-Aug-12 16:34 UTC
Re: [Ruby] get a reference to a function or method, not call it with no arguments
On Fri, 2005-08-12 at 16:43 +0100, Tom Schutzer-Weissmann wrote:> irb(main):004:0> test_for_blockdev = FileTest.blockdev? > ArgumentError: wrong number of arguments (0 for 1) > from (irb):4:in `blockdev?'' > from (irb):4 > irb(main):005:0> > > I don''t want to call the damn thing, I just want a reference to it! Or > has too much javascript clouded my brain to the way of ruby?This might be wrong but.... test_for_blockdev = lambda { |a| FileTest.blockdev? a } that should make test_for_blockdev a Proc object, so you can: test_for_blockdev.call(arg) Not quite a "reference", but I''m not sure how you would do that. Maybe a guru can set up both straight.... -Matt B