Yes, because once I decided to prank my friend by making the code crash itself if a certain comment is removed. And I forgot about it after pranking him.
Some days later I spent 2 hours trying to fogure out what the hell was crashing the code until I saw that prank.
I never had a bigger impulse to throw myself out the window before.
Except that I took advantage of the node_modules and his the code inside a package required by a package which is required by another package which is required at the top level of the main code.
Assuming this is something like Java,// is terminated by a new line. It does not affect anything on the next line. Unless he did keep it on the same line and I'm a victim of mobile Reddit formatting.
I actually couldn’t agree more. Lol. If I’m being honest, If I didn’t always use // I’d probably have a few things like this too. Albeit better comments lol
I see three reasons: it's simple, easy to use and understand. Sure if it was just simplicity # would be best, but with // you intuitively get that everything to the right of it is now a comment. The // looks and acts as a divider, thus you know not to put a semicolon in that divided section, since it's now comment and not code.
I think it works best for monke brain. Do you agree?
Ooh ooh ooh! I remember this: the scanner looks through the original source file and converts it into a string of tokens;
<INTEGER, "123">; <STRING, "\"Hello world\">, ...
stuff like that, before passing that string on to the Parser, which looks at the tokens to make sure the structure makes sense. However, when the scanner sees a comment, it simply doesn't make a token for it, meaning the Parser never sees it at all. You could have something like
int * intArray = new /*integer*/ int[/*number of elements*/ 50];
And while any human would stare at this line questioning the events that lead up to them seeing this monstrosity, the compiler wouldn't even know anything was off, because the parser would just see something like
You mean docstrings? No, this is widely different. That's a comment right in the middle of the line, docstrings live on their own lines and are used to provide documentation (at the very least through help, in most cases through stuff like Sphinx).
427
u/[deleted] May 12 '21
I bet this guys code is full with stuff like this:
int getAge() /*gets age*/;String name /*name*/;class Math() /*class for mathematic operations*/{91
u/schwarzhexe May 12 '21
just whyyy
169
u/NMO May 12 '21
That's not bad code, that's bad manners.
54
u/stickano May 12 '21
Thanks. I hate it.
35
u/Chipito13 May 12 '21
Hmmmmmmm yes floor is made of floor
81
u/--B_L_A_N_K-- if (true == true) {return true;} else {return true;} May 12 '21
Image Transcription: Code
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!
18
u/INTO_NIGHT May 12 '21
It runs but you shouldn’t write it like this
42
u/[deleted] May 12 '21
This is why // is better than /* */ don't @ me
7
u/Gaboik May 12 '21
It was to make a statement
17
u/shashankrnr32 May 12 '21
Perfect way to code in computer science examinations. Why make it simple for the reviewer? I approve this.
10
u/cAPSLOCK567 May 12 '21
placement aside, its also unnecessary
4
u/Inopmin May 12 '21
No please
3
u/SystemIntegrat0r May 12 '21
Not sure if this is still the case, but I remember the default tsconfig.json doing exactly this on some lines, but not every line -.-
3
u/Kisskissyangyang May 13 '21
Lol I’ve done that before when I sometimes want to change a value without deleting what it was previously so I can easily switch back.
2
u/Clean-Explanation-36 May 13 '21
just call the variable finalReturnValue... smh lol
2
u/deftware May 13 '21
Genius.
3
u/Encursed1 May 12 '21
I'd be the person to not notice the semicolon after the comment and put a second one in the code, then wonder why it doesn't work.
2
u/pandolf86 May 12 '21
Wow does the compiler accept this?
1
u/Hozerino May 12 '21
ohhhh I'm glad he explained it
1
u/curryoverlonzo May 12 '21
oh my god bleach my eyes
1
u/alex_schmoo May 13 '21
Wow thanks for the tip, I'm going to start using that.
1
u/[deleted] Aug 23 '21
ok this is kinda interesting
1
u/mkg11 May 12 '21
I woulda spent 10 minutes trying to find out where the error is coming from lol
0
u/[deleted] May 12 '21
[deleted] — view deleted comment