97
u/stogle1 Apr 26 '21
Junior Dev: How do I test if two booleans are true?
Senior Dev: You just && them together
Junior Dev: Coming right up!
44
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Apr 25 '21
Image Transcription: Code
public ActionResult EditGroup(Group group)
{
string fleetSuccess = string.Empty;
bool success = false;
if(action != null)
{
fleetSuccess = updateGroup(group);
}
else
{
fleetSuccess = Boolean.TrueString;
}
success = updateExternalGroup(group);
fleetSuccess += "&&&" + success;
if (fleetSuccess.ToLower().Equals("true&&&true"))
{
GetActivityDataFromService(group, false);
}
return Json(fleetSuccess, JsonRequestBehavior.AllowGet);
}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!
19
28
16
23
u/ourlastchancefortea Apr 26 '21
Hey OP how about posting the source: https://thedailywtf.com/articles/the-truth-and-the-truth
4
4
u/muzzbuzz789 Apr 26 '21
Can someone explain how this would even compile with the 'action' variable not having been defined?
25
u/JJBA_Reference Apr 26 '21
This is a method within some class. action is probably a property of the same class.
5
2
5
u/britreddit Apr 26 '21
Looks like some kind of API, ActionResult it typically used by ASP.NET to bundle replies to requests
2
u/decimaster321 Apr 26 '21
The worst thing about this example is an http-GET triggering a server side update.
1
1
u/KCGD_r Apr 26 '21
idk what's worse, the "true&&true" or group and Group being different variables
3
u/00PT Apr 26 '21 edited Apr 26 '21
I'm pretty sure that's supposed to be an instance of the "group" class. It's fairly common to name your variable the same as the class (or at least something resembling the class) if you only have one instance (you can tell it's a variable by the casing).
109
u/00PT Apr 26 '21
The beginning is actually interesting - I like how they use string.empty instead of "" and boolean.truestring instead of "true". Last part is bad, though.