Modern Programming
-
Oh, (you) (really) (like) (Lisp)?
(That's) (great!)wrote on last edited by [email protected](is great (oh (really (like-p lisp you))))
-
Because of all the garbage
One example that's giving you problems? Maybe even on a daily basis if you use it for work? What's garbage about it?
-
It doesn't make sense. I understand it, but it doesn't make sense.
I agree. If anything it should check if there is a nuumber and 0 is clearly a number.
-
In JS 0 is the same as False
They are not the same, but 0 can be implicitly converted to false.
What do you get if you do: 0 === false
-
At least you guys have ternary syntax cries in kotlin.
It's really special to not have ternary, but have Elvis.
-
They are not the same, but 0 can be implicitly converted to false.
What do you get if you do: 0 === false
Explosion?
-
print("odd" if num % 2 else "even")
That's the native python version, for those curious
Oh wow, I think I hate that... Condition between the results? Yuck.
-
In JS at least, there's a concept of truthiness and falsiness.
0
,undefined
,null
, and a few other non-boolean values are treated asfalse
if used in conditionals and logical operations, while every other value is treated astrue
. I'm pretty sure python has something similar.It does. Empty collections, 0, None
-
I think the idea is it reads more naturally, so you can read it like this
return A if statement is true else return B
Is it really more natural for a non-programmer than "if statement is true than a else b"? I can't evaluate because of decades of C, so for me the python logic is still bizarre.
-
Is it really more natural for a non-programmer than "if statement is true than a else b"? I can't evaluate because of decades of C, so for me the python logic is still bizarre.
Maybe?
For C at least it doesn't have the actual words, so you need to know what the specific symbols are
var = condition ? a : b
. In that expression we don't know what a or b are in regards to the condition.Python literally is
a if condition else b
, so it reads out what is being done. -
At least you guys have ternary syntax cries in kotlin.
in Scala, everything is an expression, including “if”, maybe kotlin is the same?