You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Person
constructor: ( @name ) ->
setNickName: ( nickName ) -> @nickName= nickName
setAge: ( age ) -> @age= age
addRoomMate: ( somePerson ) -> #Not sure about this one
return false if @roomIsFull()
@roomMates.push( somePerson )
@doSomeMoreInitialization()
and then:
john= new Person 'john'
..setNickName('jt')
..setAge(24)
or:
john= new Person'john'
john..setNickName('jt')..setAge(24)
setNickName: @ ( nickName ) -> @nickName= nickName already compiles, so you would need to come up with a new syntax. I’m not sure there is a syntax like what you’re asking for that wouldn’t be a breaking change.
Removing implicit returns has been discussed before, and isn’t currently on the roadmap. If you want a function to return undefined like in JavaScript, end your function with return by itself on a line.
I would love to see the default return value/identifier in the function statement or a undefined return
as we have in Javascript
I very often see myself adding an extra line to force a undefined or other return value.
This would also eliminate the need for ending a function with @ or this (taking up a whole line for a single @) to chain functions
Any return statement inside the function should override the default return value
for example:
The text was updated successfully, but these errors were encountered: