PDA

View Full Version : In Ruby, how do I define a []= method?


kushboy
08-19-06, 08:58 PM
I've figured out that def method[](string) is how you define a [] method, but I can't figure out the syntax for []=.

def [](string) = (string2) ? Something like that?

In case I'm not clear, I'm referring to something like:

object["string"] = "newstring"

Like an array works.