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

is / as functions #29

Closed
FlorianRappl opened this issue Jun 2, 2016 · 0 comments
Closed

is / as functions #29

FlorianRappl opened this issue Jun 2, 2016 · 0 comments
Assignees
Milestone

Comments

@FlorianRappl
Copy link
Owner

FlorianRappl commented Jun 2, 2016

I will introduce two handy functions: is() and as(). The first one checks if a given value is from a given type.

Examples:

is("String", "Test string") // true
is("Number", true) // false
is_bool = is("Boolean"); is_bool(14 ~= 7) // true

As the helpers (e.g., is_bool) are trivial to create on the fly (using currying) these won't be provided.

Similarly, there will be the as function, which is a defined way to do type casts.

Examples:

as("String", 3.5) // "3.5"
as("Matrix", true) // [1]
as("String", null) // ""

If a cast fails the result is of type "Undefined" (.NET null).

@FlorianRappl FlorianRappl added this to the 0.7 milestone Jun 2, 2016
@FlorianRappl FlorianRappl self-assigned this Jun 2, 2016
FlorianRappl added a commit that referenced this issue Jun 6, 2016
FlorianRappl added a commit that referenced this issue Jun 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant