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

Integer is not Num, only Float is #305

Open
evaporei opened this issue Sep 30, 2021 · 0 comments
Open

Integer is not Num, only Float is #305

evaporei opened this issue Sep 30, 2021 · 0 comments

Comments

@evaporei
Copy link

evaporei commented Sep 30, 2021

let jsonObj: JSON.Obj = <JSON.Obj>(JSON.parse('{"value": 24}'));
let value: JSON.Value = jsonObj.getValue("value")!;

assert(!value.isNum)
assert(value.isInteger)

jsonObj = <JSON.Obj>(JSON.parse('{"value": 4.2}'));
value = jsonObj.getValue("value")!;

assert(value.isNum)
assert(value.isFloat)

This happens because only Float extends Num, Integer doesn't extend it.

I'm only pointing this out because the README.md's example is incorrect, since the JSON parsed in it has an Integer and not a Num:

{"hello": "world", "value": 24}
@evaporei evaporei changed the title Integer is not Num, only Float Integer is not Num, only Float is Sep 30, 2021
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

1 participant