>> class Satu
>> def hello
>> puts 'hello for you'
>> end
>> end
Then you instantiate an object, write:
>> data = Satu.new
>> data.helloOther example for creating an array:
>> class Satu
>> def initialize name # constructor
>> @name = name # @ is the class data
>> end
>> def setName name
>> @name = name
>> end
>> def getName
>> @name
>> end
>> end
To instantiate an object, use:
>> data = Satu.new 'lady gaga'
>> puts data.getName # print out 'lady gaga'
>> data.setName 'luna maya' # 'luna maya' for getName
No comments:
Post a Comment