ooc-lang / rock

:ocean: self-hosted ooc compiler that generates c99
http://ooc-lang.org/
MIT License
401 stars 40 forks source link

Add a simple way of making chained method calls #973

Closed h3l1xc closed 8 years ago

h3l1xc commented 8 years ago

It will make code more concise. It's already possible, returning this from a method, but it prevents using the return value for something more useful. Here is an example:

apple := Fruit new() setColor("green") $ setType("apple") Here setType doesn't refer to the return value of setColor, but instead to the last non-chained method (here it's new, so it refers to the new instance of Fruit)

fasterthanlime commented 8 years ago

Isn't that exactly what . does ?

h3l1xc commented 8 years ago

Really? I didn't know that! Now I feel dumb :P

fasterthanlime commented 8 years ago

Don't feel bad! It must be the first time in six years somebody asks for something we already have ;)