Last active
October 1, 2015 22:34
-
-
Save zahodi/265dbe6a8d66b1f9243b to your computer and use it in GitHub Desktop.
person class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Person | |
def greet(first, last) | |
puts "Hello, #{first} #{last}" | |
end | |
end | |
person = Person.new | |
person.greet('Bob', 'Smith') | |
class Person2 | |
def initialize(name, surname) | |
@name, @surname = name, surname | |
end | |
def greet | |
"Hello, my name is #{@name} #{@surname}!" | |
end | |
end | |
person2 = Person2.new('bob', 'smith') | |
puts person2.greet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment