From: Phillip Gawlowski Date: 2008-04-30T22:33:30+09:00 Subject: Re: How to create "def method(item)= (value)" ? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I単aki Baz Castillo wrote: | 2008/4/30, Phillip Gawlowski : |> | You could also do: |> | |> | def param[]=(key,value) |> | @params[key] = value |> | end |> | |> | object.param[key] = value |> |> Oh, I'm gonna steal that idiom if you don't mind. ;) | | I'm sorry, but as I've replied in this thread that method naming | (using []) is invalid in Ruby :( Sort of. As a singleton method, you get the syntax error. But not if you define [] as a method: irb(main):001:0> def []=(key,value) irb(main):002:1> end => nil - -- Phillip Gawlowski Twitter: twitter.com/cynicalryan Blog: http://justarubyist.blogspot.com ~ "It's great to have a friend who appreciates an earnest discussion of ideas." -Calvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkgYdR8ACgkQbtAgaoJTgL8u3wCeJBjJgyJ61Uvxx29wpoiYzx+N YjUAnjvAmG8+itc/5/337GSz37rH64zm =f5M/ -----END PGP SIGNATURE-----