Ruby Basics - Classes
class HelloWorld
# This is a class method
def self.from_class
puts "Hello from a class method"
end
def say_hello
puts "hello".upcase
end
end
# Can be re-opened again
class HelloWorld
def say_hello_again
puts "hello again".upcase
end
end
# Creating an object
helloWorld = HelloWorld.new
HelloWorld.from_class # => Hello from a class method
helloWorld.say_hello # => HELLO
helloWorld.say_hello_again # => HELLO AGAIN
helloWorld.from_class # => undefined method `from_class ...