legal, but smelly. Like why is "trick" the naming convention for the function that does tricks, but "treat" is the naming convention for a property that stores the result of a function that does treats, but is named using different logic?
if it was done that way, why was the most important part done off-screen, and only the result was presented to us looking exactly like the conventional method with a typo?
imo it just takes way more bad practice and large assumptions to interpret OP's version as intentional, so if it actually was, bare-minimum should be a comment like
// [OP's name]: NOT A TYPO I did it this weirdo way on purpose
A treat is a tangible thing, a trick is more like a concept - what is a trick? It's more like an action, not an object. Do you call the toilet paper on the house a trick or the act of throwing it?
I know that in English technically they are both nouns and verbs but was just trying to use the most logical solution here. The kid is asking for a treat which is an object and is threatening with a trick which is an action so that's why.
in the phrase “trick or treat” which is massively well known, trick is a verb and treat is a noun. everyone knows this, which is why the code sample kinda makes sense and all the ESOL people debating it in the comments sound unnecessarily disputatious.
It's really not a code smell, it makes a lot of sense this way.
You could do gotTreat||performTrick() instead but wheres the fun in that? gotTreat could be an accessor too, so gotTreat() but then you'll potentially have concurrency issues.
318
u/click-to-reveal Oct 31 '26
I don't think I've ever said those words in that order before.
266
u/AlwaysHopelesslyLost Oct 31 '26 edited Oct 31 '26
Why are you executing trick and only checking for the existence of treat?
Edit: going to ignore responses because I think everybody is missing the code smell/issue I am trying to highlight.
15
u/alex_dark Oct 31 '26
First week dev humour?
13
u/MirrrorCloud Oct 31 '26
Why is treat a variable and trick a function?
7
u/GoddammitDontShootMe Nov 01 '26
Who says it in that order?
13
u/malsomnus Oct 31 '26
It really should be trick xor trick anyway.
5
u/LegitimatePants Oct 31 '26
if(treat) return;
trick();
7
u/SnowdensOfYesteryear Oct 31 '26
It’s an implied xor
11
u/Panda_Satan Oct 31 '26
trick() || treat() ;
2
u/Single-Virus4935 Oct 31 '26
treat = "No";
2
u/vm_linuz Nov 01 '26
1
u/IslayProgrammes Oct 31 '26
public function surprise ():void
{
$this.treat()??$this.trick();
}
1
u/mplaczek99 Oct 31 '26
Bro says the words backwards
1
u/GetHimABodyBagYeahhh Oct 31 '26
Is 'a rock' truthy?
1
u/KaZIsTaken Oct 31 '26
If trick doesn't return a boolean you might have an issue on your hands.
1
u/CranberryDistinct941 Nov 01 '26
This the type of shit that causes dependancy issues when the language decides that logical OR isn't control flow
1
u/IGotSkills Nov 02 '26
Hey man, treat can be a function too
1
u/Dafrandle Nov 03 '26
oh no, the 2010s are leaking out again
1
u/ntn2142 Nov 05 '26
Error: fn_pointer ‘treat’ can’t evaluate to type bool
1
u/HAHAHAOOH Oct 31 '26
It's trick or treat. PR denied.
1
u/kratz9 Oct 31 '26
One of my favorite little quirks of VB is that normal evals don't short circiut, so there are special short circuiting operators.
Trick OrElse Treat()
1
u/Valokir Oct 31 '26 edited Oct 31 '26
Got bored..
Start() { TrickOrTreat(); }
TrickOrTreat() { int ToT = Random.Range(1,2);
If (ToT == 1) {Treat();}
If(ToT == 2) {Trick();}
}
Treat() { GivePlayerCandy("Happy Halloween"); }
Trick() { GivePlayerSpiders("off my lawn ya dang kids"); }
-7
u/Bathtub-Warrior32 Oct 31 '26
Yeah this doesn't make sense.
println("trick or treat);
HallowenResponseEnum response = getResponse();
switch(response){ case TRICK: performTrick(); break; case TREAT: giveTreat(); break; default: closeDoor(); break; }
0
u/UltraGaren Oct 31 '26
Human slop
38
u/[deleted] Oct 31 '26
[removed] — view removed comment