From: Lyle Johnson Date: 2001-07-20T03:41:20+09:00 Subject: [ruby-talk:18139] Re: Delphi like properties ? > I want to implement a C extension for a GUI toolkit that supports > the same magic properties like delphi. Since you don't have to write the parentheses with a Ruby method invocation, you can just define getter and setter instance methods for the class and use those; e.g. cSomeClass = rb_define_class("SomeClass", cBaseClass); rb_define_method(cSomeClass, "text", SomeClass_getText, 0); rb_define_method(cSomeClass, "text=", SomeClass_setText, 1); Note that the "getter" methods' names are just the corresponding property names, and the "setters" are the same with an equals sign appended. To call these methods from Ruby code, write: someClassInstance = SomeClass.new someClassInstance.text = "Fred" puts "The current text is #{someClassInstance.text}" Hope this helps, Lyle