L
Li Chen
Hi all,
I try to understand some concepts in Ruby. I define two classes, one
with and the other without initialize method. In order to call the
methods defined in each class I need to call new/initialize method
first. Why is that?
Thanks,
Li
#####################
class X
def hello_1
puts 'Hello_1'
end
end
a=X.new
a.hello_1
####################
class Y
def initialize
end
def hello_2
puts'Hello_2'
end
end
b=Y.new
b.hello_2
######screen output
I try to understand some concepts in Ruby. I define two classes, one
with and the other without initialize method. In order to call the
methods defined in each class I need to call new/initialize method
first. Why is that?
Thanks,
Li
#####################
class X
def hello_1
puts 'Hello_1'
end
end
a=X.new
a.hello_1
####################
class Y
def initialize
end
def hello_2
puts'Hello_2'
end
end
b=Y.new
b.hello_2
######screen output