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 26d ago
I don't think I've ever said those words in that order before.
266
u/AlwaysHopelesslyLost 26d ago edited 26d ago
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 26d ago
First week dev humour?
13
u/MirrrorCloud 26d ago
Why is treat a variable and trick a function?
7
u/GoddammitDontShootMe 26d ago
Who says it in that order?
13
u/malsomnus 26d ago
It really should be trick xor trick anyway.
5
u/LegitimatePants 26d ago
if(treat) return;
trick();
7
u/SnowdensOfYesteryear 26d ago
It’s an implied xor
11
u/Panda_Satan 26d ago
trick() || treat() ;
2
u/Single-Virus4935 26d ago
treat = "No";
2
u/vm_linuz 25d ago
1
u/IslayProgrammes 26d ago
public function surprise ():void
{
$this.treat()??$this.trick();
}
1
u/mplaczek99 26d ago
Bro says the words backwards
1
u/GetHimABodyBagYeahhh 26d ago
Is 'a rock' truthy?
1
u/KaZIsTaken 26d ago
If trick doesn't return a boolean you might have an issue on your hands.
1
u/CranberryDistinct941 26d ago
This the type of shit that causes dependancy issues when the language decides that logical OR isn't control flow
1
u/IGotSkills 25d ago
Hey man, treat can be a function too
1
u/Dafrandle 23d ago
oh no, the 2010s are leaking out again
1
u/ntn2142 21d ago
Error: fn_pointer ‘treat’ can’t evaluate to type bool
1
u/HAHAHAOOH 26d ago
It's trick or treat. PR denied.
1
u/kratz9 26d ago
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 26d ago edited 26d ago
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 26d ago
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 26d ago
Human slop
38
u/[deleted] 26d ago
[removed] — view removed comment