Skip to content

Instantly share code, notes, and snippets.

@ethnt
Last active December 30, 2015 10:29
Show Gist options
  • Save ethnt/7816282 to your computer and use it in GitHub Desktop.
Save ethnt/7816282 to your computer and use it in GitHub Desktop.
function HelloWorld (name) {
this.name = name;
}
HelloWorld.prototype.sayHello = function() {
return "Hello there " + this.name;
}
var hi = new HelloWorld("Ethan");
hi.sayHello(); // => "Hello there Ethan"
class HelloWorld:
def __init__(self, name):
self.name = name
def say_hello:
return "Hello there " + self.name
hi = HelloWorld("Ethan")
hi.say_hello #=> "Hello there Ethan"
class HelloWorld
def initialize(name)
@name = name
end
def say_hello
"Hello there #{@name}"
end
end
hi = HelloWorld.new("Ethan")
hi.say_hello # => "Hello there Ethan"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment