Skip to content
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

Extend length method to work with strings #2110

Merged
merged 1 commit into from Mar 28, 2019
Merged

Conversation

iaman
Copy link
Contributor

@iaman iaman commented Feb 5, 2016

Extends the length method to allow it to check string length as well; perhaps not terribly useful, but it seems odd to have a length method that doesn't work with a basic type that has a length property.

Author:    Ian O'Dea <ianodea@gmail.com>
@kizu
Copy link
Member

kizu commented Feb 5, 2016

Thanks for the PR! While this can be a useful feature, it can break someone's code due to how lists work in Stylus: someone could use the current behaviour of length() to check if the input is a list, expecting a single string to be 1, for example.

While we don't have proper arrays, I'd propose to add a new bif for this, named strlength for example, so there won't be conflicts with the existing code.

Also, it would be nice if this bif did type coersion, so, for example, it could also accept indents and function names as input and return their string length.

@iaman
Copy link
Contributor Author

iaman commented Feb 8, 2016

@kizu Sounds good, I'll get hacking on it later today :)

@TerraTech
Copy link

For those that TLDR; length() was extended to support string type in release: v0.54.6
https://github.com/stylus/stylus/releases/tag/0.54.6

[As an aside, it hasn't been added to the Stylus documentation as of yet.]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants