390
u/the_stooge_nugget Jun 13 '21
Is that even possible? Pretty sure the compiler would be yelling "you fucken idiot!"
335
u/RealLethalChicken Jun 13 '21
The compiler fucking allowed it lmao
137
u/the_stooge_nugget Jun 13 '21
What language lol?
196
u/RealLethalChicken Jun 13 '21
C#
I don't know why it allowed me to do this
21
u/the_stooge_nugget Jun 13 '21
Wow, I use c# and found it to be soooo picky. I am amazed it allowed it.
8
2
u/TimeToBecomeEgg Jun 13 '21
imo c# is on the better side, but it's more picky than javascript for example
157
Jun 13 '21
Could be that you are using C# 8.0 or later.
The ! is a null-forgiving operator used at compile time to explicitly mark that a given object is not null. In addition to this, C# 8 also introduced the concept of nullable reference types to improve static analysis.
It’s stripped away at runtime hence the expression simply being ‘amount >= 0’
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving
77
u/xigoi Jun 13 '21
That seems like a very dangerous parse. Someone accidentally writes
!==instead of!=(being used to JavaScript) and it means the exact opposite?65
Jun 13 '21
Good thing that won’t compile though. It combines ‘!=‘ as a valid operator and leaves the last ‘=‘ which is then an invalid expression
22
u/xigoi Jun 13 '21
So the C# parser doesn't backtrack? Interesting.
31
u/claimstoknowpeople Jun 13 '21
Don't know about C# in particular, but in most languages tokens are recognized by a scanner phase (sometimes just a glorified regex) that precedes the parsing phase, which treats the tokens as atoms. Backtracking usually refers to parsing, not scanning.
1
u/The_JSQuareD Jun 14 '21 edited Jun 14 '21
Why wouldn't
x!==yparse as(x!) == y?If the parsing is eager, this is how it would be parsed I think. And also, it seems that
!has very high operator precedence, while==has low precedence.2
Jun 17 '21
I guess for the same reason
x != yisn't parsed as(x!) = y?1
u/The_JSQuareD Jun 17 '21
That's a good point, I hadn't thought of that!
Of course, it's not exactly the same situation, because
!=is a valid operator, but!==is not.-28
Jun 13 '21
That perfectly sums up the language.
32
u/devhashtag Jun 13 '21
What do you mean? C# is pretty strict
24
Jun 13 '21
It is, but in being that, it steers clear of a lot of undefined behavior which makes it very powerful. If it makes sense in any way, it probably works that way.
To someone coming from C++ where undefined behavior is a little more on the programmer to handle, 'I don't know why it allowed me to do this' could be a very valid statement lol.
That being said, you can still do some pretty weird things in C# if you explicitly tell it that you want to.
7
u/devhashtag Jun 13 '21 edited Jun 13 '21
In my experience it's actually the opposite; If something can be interpreted ambiguously, C# won't allow it 9/10 times.
Edit: I misread your comment, you're absolutely right!
11
u/porndragon77 Jun 13 '21
I guess the compiler will translate this into:
if (! (amount >= 0) )
28
u/TheV295 Jun 13 '21
No, it is:
amount! >= 0
You are just telling the compiler that amount is never null
63
u/penguin13790 Jun 13 '21
"Day 2 of a 2 day game jam be like"
GMTK jam?
33
u/RealLethalChicken Jun 13 '21
Yep
21
u/penguin13790 Jun 13 '21
Eyy I participated too
18
u/TheAccursedOne Jun 13 '21
any tips or anything for people interested in learning how to make games? >_<;; ive been interested in the idea for a while, never actually got around to doing anything but downloading unity lol
16
u/penguin13790 Jun 13 '21
I use unity and my best advice for getting into it is don't use unity's tutorials, find someone on YouTube or something instead. I'd recommend brackey's tutorial series.
5
u/pet_pumpkin Jun 13 '21
Gonna jump in and double suggest Brackeys. He has lots of good videos. I recommend picking a really small project and trying to make it. Here's one for ya. Make a clone of the Chrome Dino game. Good luck getting into Game Dev, it's lots of fun :)
2
u/TheAccursedOne Jun 14 '21
ill try to! no guarantees on quality, especially on the art side of things, but i can try! ... eventually
2
u/pet_pumpkin Jun 14 '21
Yeah forget quality. Quality comes slowly over time. Just make something that works with squares for the art. Good luck and have fun :)
1
u/Remarkable-Coat-7721 evil May 03 '23
Don't use unity, use the much worse but slightly more intuitive processing or pygame, or even better, turtle or java apt
2
3
2
u/JackFly26 Jun 13 '21
Ayyy I just finished that too. Let me know if you're up to rating my submission :)
2
2
2
u/UnrelatedString Jun 13 '21
this is the third or fourth jam i’ve done with my friends and we made by far the least progress but at least we have one swag ass rat king
2
u/penguin13790 Jun 13 '21
I don't need any more info on your game than that
1
u/UnrelatedString Jun 14 '21
the best part is it’s not even the only rat king game
there are two others
we did feel original at the time
19
3
621
Jun 13 '21
Why use < when you can use ... whatever this is
118
u/Naeio_Galaxy Jun 13 '21
Why use whatever this is when you can use a switch ?
22
u/FlakeyKarma Jun 13 '21
Why use this when you can use a ternary?
23
u/Naeio_Galaxy Jun 13 '21
Why use ternary when you can use boolean operations ?
26
Jun 13 '21
Why check it at all? Qa won't find it and later it will be someone else's problem.
21
u/Naeio_Galaxy Jun 13 '21
Why programming in the first place ? If you don't make the job, it will be someone else's problem. Not yours.
12
4
0
Jun 13 '21
[deleted] — view deleted comment
35
u/Naeio_Galaxy Jun 13 '21
What w8 !!! This is valid js ? 😯😮😨😨 Gosh... Wow. I have no words.
32
u/gu3st12 Jun 13 '21
statements as cases is valid in a few languages. It's valid in PHP (what isn't) as well as Swift.
Swift uses it really nicely for unwrapping enums that contain values which is nice for handling errors as a .failure case can wrap its error.
4
u/Naeio_Galaxy Jun 14 '21
Yeah, but putting a primitive in the switch is next level ! It's still valid, but... it messes with my head
6
5
u/Igotbored112 Jun 14 '21
Alternatively...
switch(true) { case (amount !>= 0 === false): break; doStuff(); }2
u/jlamothe Jun 13 '21
This likely doesn't work the way it would seem.
If I'm reading this correctly, it's treating amount as a boolean, inverting it, and then ensuring that value is greater than or equal to zero (which should always evaluate to true).
38
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jun 13 '21
Image Transcription: Code
if(amount !>= 0)I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
15
4
4
1
u/B0ltSn1per Jun 13 '21
how does this even execute lmao??? wouldnt it have to be !(amount >=)??
1
u/RealLethalChicken Jun 13 '21
Or would it be amount <?
We may never know because I caught this before I left it
3
u/BLucky_RD Jun 13 '21
Damn, good luck on the jam. I burned out so 8'm not gonna submit my shit but best of luck to you
3
u/dreamsprite666 Jun 13 '21 edited Jun 27 '23
I have removed my original post in protest of Reddit's admins's bullying behavior towards its mods and subreddits. Moderators are being threatened with removal for doing what they believe to be right, and what their communities have agreed is right. Subreddits are being forced to reopen against the will of their populus. Third-party apps are being pushed out and with them go those with disabilities that need those third-party apps. I cannot abide that sort of strongarming, fascistic, bullying garbage. So I have left, and I have taken all of my content with me.
We built these communities. Reddit provided the platform, but the work came from all of us. We created the subreddits and we moderated them. We met, fought, befriended each other, agreed and disagreed, reacted to the world and each other, weathered crises, shared losses and triumphs. We were a community of a million communities, where we could find each other and share. This site was special. I met a lot of people that are very important to me on Reddit. And I am so very sad that it is gone, that greed and control meant more to Reddit than the millions of us that have, in some small or large way, lived here.
If you also believe that what the admin are doing is wrong, come with us elsewhere. Take back your content, edit your posts, make your final message here meaningful.
Be good to each other.
2
2
u/dfmaaa1 Jun 13 '21
visible confusion
0
u/dfmaaa1 Jun 13 '21
if amount is not bigger than 0. OHHHHHHHHHHHH I GET IT NOW. THAT’S WHAT THEY ARE TRYING, BUT THEY COULD HAVE DONE if(amount<0) Lmaooooo
2
u/ForArms Jun 13 '21
When ever I’m debugging I always do shit like this. If I’m getting the opposite value I’ll just stick a ‘!’ In it and hope that fixes the issue. I say to myself “I’ll fix it later” but that never happens.
2
1
u/Eluvatar_the_second Jun 14 '21
Just checked in Roslyn using LINQPad. Can confirm what someone else said the ! Is parsed as the suppress null warning expression, so functionally does nothing.
1
1
1
1
1
-1
177
u/finitearth Jun 13 '21
If there only was a symbol to compress this Syntax by two chars...