Post A1dVwsYlD2AYAI9VIG by winniehell@octodon.social
(DIR) More posts by winniehell@octodon.social
(DIR) Post #A1dVwsPXlInRhhq8vY by blinry@chaos.social
2020-11-26T20:35:42Z
0 likes, 0 repeats
Considering participating in https://adventofcode.com again this year! But which programming language should I use?
(DIR) Post #A1dVwsYlD2AYAI9VIG by winniehell@octodon.social
2020-11-27T11:31:07Z
0 likes, 0 repeats
@blinry I used Kotlin last year and can really recommend it. It was a lot of private fun for each pair: https://gitlab.com/winniehell/adventofcode-2019/blob/a277c0b6476ddf2585aef626f51ee9023a62e668/src/main/kotlin/day10/AsteroidMap.kt#L15
(DIR) Post #A1dVwskSVXWikZcqWm by blinry@chaos.social
2020-11-27T21:40:14Z
0 likes, 0 repeats
@winniehell I don't know what the !! operator does, but it amuses me! :D
(DIR) Post #A1dVwstJyacFC3lvLE by thor@pl.thj.no
2020-11-27T21:46:29.686420Z
0 likes, 0 repeats
@blinry @winniehell in C, it's an unary operator that interprets the operand as a boolean value and inverts it, and then inverts it again, resulting in the *interpreted* boolean value of the operand. in C, any non-zero number is true, and if given as the operand to !!, will evaluate to 1, while everything else will evaluate to 0.
(DIR) Post #A1dW4SVTxOoRgEEWR6 by thor@pl.thj.no
2020-11-27T21:47:57.137183Z
0 likes, 0 repeats
@blinry @winniehell you might call it the not-not or double negative operator
(DIR) Post #A1dWEGYLFwMZVAFOIy by thor@pl.thj.no
2020-11-27T21:49:43.589584Z
0 likes, 0 repeats
@blinry @winniehell you could, for increased readability, rewrite it as x ? 1 : 0.
(DIR) Post #A1dWM3gWyyu5uQnFcu by thor@pl.thj.no
2020-11-27T21:51:08.649743Z
0 likes, 0 repeats
@blinry @winniehell (well, if ternary conditional expressions are your idea of "more readable")
(DIR) Post #A1eXnLm4853IwWv53w by winniehell@octodon.social
2020-11-28T09:39:42Z
0 likes, 0 repeats
@thor @blinry It is the same in other languages (such as JavaScript or Java).But of course it would be boring if Kotlin stays consistent with those.Therefore they have chosen to make it the "assert not-null" operator which throws an exception if the expression was null but otherwise continues to operate on a non-nullable type: https://kotlinlang.org/docs/reference/null-safety.html#the--operatorIn TypeScript this would just be ! (at the end of an expression): https://www.typescriptlang.org/docs/handbook/advanced-types.html#nullable-types
(DIR) Post #A1eXnLwLVrH9SPjI5Q by thor@pl.thj.no
2020-11-28T09:41:57.933592Z
0 likes, 0 repeats
@winniehell @blinry not sure how boolean true/false has anything to do with null values, other than the fact that the value of NULL in C is typically defined as (void*)0
(DIR) Post #A1eY0zaHQcIsAxuc9A by winniehell@octodon.social
2020-11-28T09:42:55Z
0 likes, 0 repeats
@thor I think @blinry was referring to the !! operator in the Kotlin code I linked above, not the !! operator in C. 🙂
(DIR) Post #A1eY0zooYZvgu2iDnk by thor@pl.thj.no
2020-11-28T09:44:27.415362Z
0 likes, 0 repeats
@winniehell @blinry oh so you're saying it means something else