-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a 'length operator': #some_array #3637
Comments
|
Yeah, forgot about that... better than I'm used to the valid characters for Lua identifiers, which is a much smaller set of characters than what JS (and Coffeescript) will allow. I'd suggest :some_object as it looks almost like a range index, which might make people think of the length -- but it's not as clear as what Lua has with #some_object. I dunno, I guess this suggestion can't work :3 |
I don't personally see the value of adding an entire operator for just getting the length of arrays. If you're doing it a lot in some part of you code, just alias it.
|
It's sad to know that there are not enough operators for coffee to achieve it. |
It's nothing to do with a lack of operators. If you have an operator for |
@carlsmith In Lua we just have # for quickly fetching the length of a table/hash/Object. We don't really lend ourselves to 'operator cancer'. Oh well, # is more common as the comment prefix.... I don't hate it |
Hi. To put it short: I'm from Lua. In Lua we have the '#' operator to basically return the .length of an array. Arrays in Javascript are just objects with number keys -- in Lua this is the same, but the # length operator actually returns an internal/private C member tracking the array part of a Lua table.
ANYWAY: I would love to see this operator brought to Coffeescript. Yes, I am biased -- I'm used to using #. I love Coffeescript and this suggestion is purely cosmetic -- I don't often need .length because of Coffeescript's for loop syntax, but for other object types I'd love to see those .length's disappear.
(Please and thank you?)
this: #some?.thing?.here?
becomes: (some !== undefined && some.thing !== undefined && some.thing.here !== undefined && some.thing.here.length)
I'll look into making a patch but I am pretty new to Coffeescript. I love it so far <3
The text was updated successfully, but these errors were encountered: