Displaying 1 result from an estimated 1 matches for "say_what".
2011 May 13
4
unexpected results when extending methods to class Class and class Object
...e/classes/Object.html
http://www.ruby-doc.org/core/classes/Class.html
First, let''s resolve the simple distinction between an Object and Class
as envisioned by Smalltalk but within the Ruby context:
#A class is a template used to define methods and properties
class Hello
attr_accessor :say_what
private
def say_what(txt)
puts txt + ''my friend''
end
end
#Objects are the things actually created out of a class and can be used
in client code
@obj = Hello.new
@obj.say_what "hello"
@obj2 = Hello.new
@obj2.say_what "bye"
Both @obj and @obj2 instance...