8. Object Orientation
5.class
=> Fixnum
class Sample
class Sample
def hello2
def hello
puts “hello2”
puts “hello”
end
end
end
end
obj.hello2
obj = Sample.new
obj.hello
Follow me @vagmi
9. Object Orientation
class << obj2
def hello3
obj2 = Sample.new
puts “hello3”
obj2.hello1
end
hello
end
=> nil
obj2.hello3
obj2.hello2
hello3
hello2
=> nil
=> nil
obj.hello3
# error occurs
Follow me @vagmi
10. Data Types
a = [1,2,3,”hello”,[‘a’,’b’,’c’]
a << “another object” hsh = {}
a[4] hsh = {“a”=>1, “b”=>2}
=> “hello” hsh = {“asdf”=>1,2=>”asdf”}
a[4] hsh[a] = “key can be anything”
=>[‘a’,’b’,’c’]
Follow me @vagmi