Last active
January 20, 2017 15:26
-
-
Save antonkartashov/dfff3eaa5f2404ca8f0fe2fc00cd89f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Function.prototype.define = (prop, desc) -> | |
Object.defineProperty(this.prototype, prop, desc) | |
class Name | |
constructor: ({@first, @last}) -> | |
@define "full", | |
get: -> | |
return "#{@first} #{@last}" | |
set: (value) -> | |
array = value.split(" ") | |
@first = array[0] | |
@last = array[1] | |
name = new Name | |
first: "Anton" | |
last: "Kartashov" | |
print name.full | |
# » "Anton Kartashov" | |
name.full = "Clark Kent" | |
print name.first | |
print name.last | |
# » "Clark" | |
# » "Kent" | |
name.last = "Gable" | |
print name.full | |
# » "Clark Gable" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment