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

check the type like Python? #266

Open
ThreadSanitizer opened this issue Sep 20, 2023 · 1 comment
Open

check the type like Python? #266

ThreadSanitizer opened this issue Sep 20, 2023 · 1 comment

Comments

@ThreadSanitizer
Copy link

For example:

>>> x = 123
>>> type(x) is int
True
>>> type(x) is str
False
>>>

How to do this in Starlark?

@stepancheg
Copy link
Contributor

In starlark spec starlark, the way to do it is:

type(x) == type(1)

in starlark-rust we have isinstance:

isinstance(x, int)

which I thing might be helpful addition to starlark spec, some basic form, i.e. mandate isinstance should work for builtin constructors like int or list.

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

No branches or pull requests

2 participants