This would be so clean as a when statement though....
# announcements
a
This would be so clean as a when statement though... Unless I'm not reading it right, which is totally possible.
Copy code
val focusedInput = when(Object.keys(error)) {
	"phonebookId", "phonebook_str", "message", "image", "buttonLink", "messageSms" -> Object.keys(error)
	else -> "false"
}
f
I don't even think you'd need a "when", but tbh I'm not even sure wtf this is supposed to be doing
👍 1
a
Exactly why it's possible I'm not reading it right haha
f
I'm pretty sure it always ends up doing
false.shift()
as Object.keys returns an array which should (at least in a sane language) never equal any of those strings
a
I don't know enough JS apparently. ¯\_(ツ)_/¯
f
oh actually it's just
Object.keys(error).shift()
me neither, and I'm glad I don't 😛
just having some PTSD of my ActionScript 2.0 days
j
according to my javascript console, this resolves to true
Object.keys({"hello" : true}) == "hello"
f
well that's horrifying
j
that's the fun part with javascript, you never know wether something basic works until you try
f
["hello"] == "hello" > true
a
Reason number one why I hate dynamically typed languages: Can you tell me the type of
focusedInput
? Is it String or Boolean?
f
it's an array 😛
or false
a
So, is it an array or boolean? Yes.
f
Shrödinger's variables
😂 1
j
so in the end it's either
Object.keys(error).shift()
or an exception, because
false.shift()
don't work, even in javascript
a
The fact that you can write this code gives me anxiety. It takes a special person to work with dynamically typed languages.
j
yes, masochists
f
also known as "interns"