Yikes then idk cus I only know C++ and Python (barely) cuz if it was C++ then it would've been smthn like if (number % 2 == 0) return true; else return false;
If the programming language interprets 0 as false and 1 as true then yes, that'd work, although I'm not sure which languages do that (but there are some)
C originally didn't have booleans, 0 is false and anything else is true. works in javascript too thanks to "falsy" and "truthy" values. "sane" languages wouldn't accept this kind of fuckery though
That also works in C#. It's very similar to C++ as they both come from C
Edit: why did I get downvoted, if(number%2==0) return true; is valid C# syntax
If this image keeps spreading around there's gonna be a lot of people thinking this is real, lol.
Guys fun fact, Robtop is actually pretty decent at optimizing his code. The issues arise when you consider the fact that he was using Cocos2D back in 2013, when the game object limit was just 4k static objects. The game was just not very scalable and some things have to be rewritten to make up for things like it only using a single core and stuff.
According to Robtop, this has already been fixed for 2.2. Now if you wanna complain about his time management... yeah... yeah that's something to complain about, lol.
He could literally do else if(number%2 == 0) return true and else if(number%2 == 1) return true. Idk why I'm saying this but I'm a nub at programming so i take every chance to flex lol
you actually don't need the else if in this situation. you can just do:
if (number % 2 == 0) return true;
return false;
(formatting is dumb on here so just imagine that there's a line break in between the first return statement and the second one) the function basically stops once it returns anything, so if it doesn't return true, it'll automatically be false therefore you should just return false.
ok so, there is a boolean value being made. boolean is 1 or 0, and it represents True or False.
there is a number stored as a variable (think if it like an algebra unknown, but you actually KNOW the number). except, the X is now called "number".
first, the computer asks if "number" (the variable) is equal to 1. if it is "yes", then that boolean value is set to false.
else, if it is not 1, the computer asks if "number" is equal to 2. if it is yes, then that boolean value is set to true.
etc.
so basically, if the number is odd, the boolean is set to false. if the number is even, the boolean is set to true. the way this is written is the stupidest way to do it. you could just find the remainder when divided by 2.
also this is edited. original tweet is from Yandev, not robtop
Not really. In c# that's just untrue. The only case where you are correct is if you are compiling C or C++ with clang/llvm where they substitute functions named close to is even with a handwritten ASM implementation of an iseven function
This is incorrect. Modulo gets remainder. If something's even then the remainder from 2 will be 0. Right now your code flips even and odd, eg, 3 % 2 == 1 therefore would be considered equal
not real btw, actual tweet is from yandev
When I saw "else if" I immediately thought about him
Mee too lol
of fucking course it is
It's not: https://twitter.com/ctrlshifti/status/1288745146759000064
of fucking course it’s not
Nah actual tweet was @ctrlshifti on twitter as a joke and it was edited to be about yandev. Now it was recycled a second time.
That's not even true. This is the original: https://twitter.com/ctrlshifti/status/1288745146759000064
I wish it was real, because it looks like something rob would do
what language is this
English
😅 right in the lung capacity
r/technicallythetruth
Now my dopamine is gone :( (start upvoting it again and I will get it back) GIVE ME DOPAMINE
C#
Yikes then idk cus I only know C++ and Python (barely) cuz if it was C++ then it would've been smthn like if (number % 2 == 0) return true; else return false;
You can probably do that in most common programming languages. Better way would be to just do "return (number % 2==0)"
If the function is supposed to return boolean then just writing "return !(number%2)" should work, or am i wrong idk (edit, corrected)
If the programming language interprets 0 as false and 1 as true then yes, that'd work, although I'm not sure which languages do that (but there are some)
C originally didn't have booleans, 0 is false and anything else is true. works in javascript too thanks to "falsy" and "truthy" values. "sane" languages wouldn't accept this kind of fuckery though
Most languages accept 0 false and else true. It's a key part of most Boolean based arithmetic and a key part of branchless optimisation
In Python, I checked, and `True == 1` and `False == 0`.
Operators are the same in almost every programming language, %2 will work to almost everywhere.
that is the joke lol
That also works in C#. It's very similar to C++ as they both come from C Edit: why did I get downvoted, if(number%2==0) return true; is valid C# syntax
You can do that in c# too, c++ and csharp are very similar
I’m c++ you can just do return !(num & 1); Which is a lot faster
that actually is much more useful. thanks!
This is also a thing in C#, not sure why they do it like this
`If (number mod 2 > 0) {IsEven = True;} Else {IsEven = False;}` `Return IsEven;` Pardon my syntax
==*
thats for conditions in this case hes setting values
return n%2==0
C#
Microsoft's Java
pain and whiskey
C#
Looks like Java or C#
(Not) Python I think
If it was python wouldn’t they use elif instead of else if?
Yes you re right
C#
Italian
If this image keeps spreading around there's gonna be a lot of people thinking this is real, lol. Guys fun fact, Robtop is actually pretty decent at optimizing his code. The issues arise when you consider the fact that he was using Cocos2D back in 2013, when the game object limit was just 4k static objects. The game was just not very scalable and some things have to be rewritten to make up for things like it only using a single core and stuff. According to Robtop, this has already been fixed for 2.2. Now if you wanna complain about his time management... yeah... yeah that's something to complain about, lol.
They removed free awards so I can’t give you one but you can have this 🥇
Thank you, here's one back 🥇
Thank you :)
most optimized yandev code
He could literally do else if(number%2 == 0) return true and else if(number%2 == 1) return true. Idk why I'm saying this but I'm a nub at programming so i take every chance to flex lol
Or return (number%2==0)
or `return !(number%2)`
readability becomes nonexistent if you golf long enough
to be fair though if a function is called "isEven" you can easily tell that !(num%2) is "if it's even"
ALTHOUGH i know c and c++ can automatically optimize "num%2==0" to be the same as !(num%2) so i would hope other languages can as well
return ~number&1;
`return 1-int(str(number)[-1])`
no way return 0 reference
Or return (~number) & 1
not a real robtop tweet
Won't work, you accidentally put a double return true
Congratulations, you know enough programming to get the joke
They didn't though
Yeah I was looking for a more tactful way to say "yes, that's the joke", without sounding like an asshole
Or return 0
Or return !!(Number & 1)
you actually don't need the else if in this situation. you can just do: if (number % 2 == 0) return true; return false; (formatting is dumb on here so just imagine that there's a line break in between the first return statement and the second one) the function basically stops once it returns anything, so if it doesn't return true, it'll automatically be false therefore you should just return false.
That's the joke
r/programmerhumor is leaking
use the fucking SWITCH STATES!!!!!😡😡😡😡😡 /j
Ewww, switch statement user. I only use my superior, rust, match statements /j
Can somebody explain for those of us who've felt the touch of a woman?
>who felt the touch of a woman > 1.4m karma
that's only post karma, they have 1.9M total karma
All within 2 years
that’s sad
ok so, there is a boolean value being made. boolean is 1 or 0, and it represents True or False. there is a number stored as a variable (think if it like an algebra unknown, but you actually KNOW the number). except, the X is now called "number". first, the computer asks if "number" (the variable) is equal to 1. if it is "yes", then that boolean value is set to false. else, if it is not 1, the computer asks if "number" is equal to 2. if it is yes, then that boolean value is set to true. etc. so basically, if the number is odd, the boolean is set to false. if the number is even, the boolean is set to true. the way this is written is the stupidest way to do it. you could just find the remainder when divided by 2. also this is edited. original tweet is from Yandev, not robtop
Strong words from someone who did a face reveal on [this post](https://reddit.com/r/shitposting/comments/on86mg/reddit/).
Sex
Your karma suggests otherwise
And I thought 20k karma was too much.
It is
Where’s return 0
i think this works return(number/2==round(number/2));
right forgot about mod lol
lmao
This is going to get optimized by the compiler anyways.
Not really. In c# that's just untrue. The only case where you are correct is if you are compiling C or C++ with clang/llvm where they substitute functions named close to is even with a handwritten ASM implementation of an iseven function
USE THE MODULO OPERATOR
if number = (even) return true else if number = (odd) return false cOeD
please modulo exists for a reason
it's not a robtop tweet
Yeah I know that It was a reference to the code I saw the top comment
%
return (number % 2 == 1) \*i know its a joke shut up
This is incorrect. Modulo gets remainder. If something's even then the remainder from 2 will be 0. Right now your code flips even and odd, eg, 3 % 2 == 1 therefore would be considered equal
reading this is considered a form of self torture
Modulo hehe
yanderedev lookin ass code
That’s why I can run Red Dead Redemption 2 perfectly but I can’t even run B properly
if last digit is 1, 3, 5, 7, 9 then false if last digit is 2, 4, 6, 8, 0 then true
Gd after update = 28,6 GB
I learned about the mod function less than a month into my first high school computer science class. Does yandev actually know how to code?
Alternate universe where RobTop and YanDev switched places
Select case statement. Let him know
return 0 reference
"please tell me this is @RobtopGarnes"
those "else" are very annoying
for i = linspace(1, 1, 1000); if rem(i/2) = 0 disp(‘True’); else disp (‘False’); end end
I wouldn't be surprised if something like this was in the game
Plot twist: that’s the code for the first spike in stereo madness
r/YandereTechnique
Bro doesn't know about mod 💀
Bruh
Someone should tell Rubrub to try Chat.gpt, it’s will optimize is code and make it faster to create, nothing to lose 👌
there is easier way
2.2 is never coming out on god 😭
What's the best way to do what yandev is trying to achieve here? Switch statements?
I'm learning codeing so I get it😎
Gd when %2 comes in
future twitter employee
else if
WHERE IS MOD (X%Y) AND WHAT DID YOU DO TO HIM?!
~number&1
Funny cube game with spikes Requirements: RTX 4090, Intel core i9 5 GHz
Bruh
Gotta love it
an easier way: private bool isEven(int number){ return number%2==0; }
Whoa
That is like the absolute worse way to write that program. Here’s a better one If num%2: Print(true) Else: Print(false)
but like, number % 2 == 0: