Is this considered a bug or am I really required t...
# getting-started
j
Is this considered a bug or am I really required to specify that it's an
Int
and not a
Long
?
v
I guess as soon as you use it (assign it, give it as argument, ...) the ambiguity resolves.
j
maybe I just hit a rare case 😛
Copy code
val myString = """hello(value: "something")"""
val invalid = (myString.sumOf { if(it == '"') 1 else 0 } % 2) != 0
I decided to just make them
Long
's as it's easier to write an
L
behind the numbers
I have written a simple parser and was using
sumBy
but this function has been deprecated, but moving to
sumOf
brought this issue.
t
FYI, there is
String.count
, i.e.:
Copy code
val invalid = (myString.count { it == '"' } % 2) != 0
This also resolves the ambiguity :D
👍 2