Created
October 3, 2012 18:27
-
-
Save mattions/3828819 to your computer and use it in GitHub Desktop.
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
# The Greeter class Python | |
class Greeter: | |
def __init__(self, name): | |
self.name = name.capitalize() | |
def salute(self): | |
print "Hello %s!" %self.name | |
# Create a new object | |
g = Greeter("world") | |
# Output "Hello World!" | |
g.salute() |
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
# The Greeter class Ruby | |
class Greeter | |
def initialize(name) | |
@name = name.capitalize | |
end | |
def salute | |
puts "Hello #{@name}!" | |
end | |
end | |
# Create a new object | |
g = Greeter.new("world") | |
# Output "Hello World!" | |
g.salute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment