29 lines
354 B
Text
29 lines
354 B
Text
|
|
class CoffeeMaker{
|
|
init(coffee){
|
|
this.coffee = coffee;
|
|
}
|
|
|
|
brew(){
|
|
print "Enjoy your cup of " + this.coffee;
|
|
|
|
// No reusing the grounds!
|
|
this.coffee = nil;
|
|
}
|
|
}
|
|
|
|
var maker = CoffeeMaker("coffee and chicory");
|
|
maker.brew();
|
|
|
|
class Oops{
|
|
init(){
|
|
fun f(){
|
|
print "not a method";
|
|
}
|
|
this.field = f;
|
|
}
|
|
}
|
|
|
|
var oops = Oops();
|
|
oops.field();
|
|
|