Re: Create a method with name, containing illegal characters
- From: "Robert Dober" <robert.dober@xxxxxxxxx>
- Date: Thu, 1 Nov 2007 00:19:51 +0900
On 10/31/07, Phrogz <phrogz@xxxxxxx> wrote:
On Oct 31, 7:34 am, kylichuku <Kirill.Isha...@xxxxxxxxx> wrote:Cool I did not know one could do this
I need to create a method with name, that contains '-' character. Is
it possible, and if the answer is "yes", how can I do it?
lim2:~ phrogz$ irb
irb(main):001:0> class Foo
irb(main):002:1> define_method("a-b") do
irb(main):003:2* puts "What a strange need!"
irb(main):004:2> end
irb(main):005:1> end
=> #<Proc:0x00354328@(irb):2>
irb(main):006:0> f = Foo.new
=> #<Foo:0x34f454>
irb(main):007:0> f.a-b
NoMethodError: undefined method `a' for #<Foo:0x34f454>
from (irb):7
from :0
irb(main):008:0> f.send( "a-b" )
What a strange need!Not strange at all, how often did I
gsub("-","_") in my DSLs
Cheers
Robert
--
what do I think about Ruby?
http://ruby-smalltalk.blogspot.com/
.
- References:
- Create a method with name, containing illegal characters
- From: kylichuku
- Re: Create a method with name, containing illegal characters
- From: Phrogz
- Create a method with name, containing illegal characters
- Prev by Date: Re: Find out the mac address
- Next by Date: Re: Array and ASCII Help needed...
- Previous by thread: Re: Create a method with name, containing illegal characters
- Next by thread: Re: Create a method with name, containing illegal characters
- Index(es):
Relevant Pages
|