Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo(object):
- def __init__(self):
- self.myattr = 0
- def bar(self):
- self.myattr += 1
- return self
- var Car = function () {
- return {
- gas : 0,
- miles : 0,
- drive : function (d) {
- this.miles += d;
- this.gas -= d;
- return this;
- },
- fill : function (g) {
- this.gas += g;
- return this;
- },
- };
- }
- var c = Car();
- c.fill(100).drive(50);
- c.miles => 50;
- c.gas => 50;
- a.doA()
- a.doB()
- a.doC()
- a.doA().doB().doC()
- function doA():
- return new A(value + 1)
- function doB():
- return new A(value * 2)
- function doC():
- return new A(sqrt(value))
- foo.modify1().modify2()
- # without `return self`
- foo.modify1()
- foo.modify2()
- foo = foo.modify()
- # without `return self`
- foo.modify()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement