640

Everyone always says the previous developer was crap, sometimes you're right

Comments
  • 3
    so right, man
  • 11
    Wow... elegant
  • 7
  • 5
    Just WOW !
  • 3
    Ahaha perfect!
  • 4
    I have no words for this...
  • 1
    Jesus
  • 0
    😭😭😭😭😭😭
  • 0
    😂😭💀
  • 11
    Actually now that I'm thinking about it it kind of makes sense if isEnabled is a Boolean value fetched via an Ajax request of some sort and that fetched value's type was set as a string instead of a Boolean (and boy does this happen a lot for me with express), it would then make sense to normalize the value to a string just to be safe. Although he did get me at the double equals operator... Especially since the value is already normalized...
  • 1
    I'm not fluent in script, so I don't understand 😭
  • 0
    The best rants I have read yet
  • 0
    Okay, but if it is a string then why .toString ()
    Sound like it should just check for isNull
  • 1
    true.toString() === "true".toString()

    They didn't know the type. It must have been possible to get a string back from an api call. That is the true bug. The service should return booleans.
  • 0
    Why the F...?!
  • 2
    @danielkalen .equals() should then be used, at least in Java. But yes, I think your description is quit good, I have to go that way often when I have to evaluate values taken from html attributes for automated web tests...
  • 8
    Should have used toLower(), just to be safe!
  • 0
    Perfect!!
  • 0
    Genius.
    And, int to string.
    Float to string.
    "What a data-type!"
  • 0
    in love with string...lol
  • 0
    kill it, before it lays eggs
  • 0
    saw this today too.

    isEnabled.toString().toLower() == "true"
  • 0
    @Cod-eLurkin isEnabled() return a Boolean true o false, there's no need to cast to string to evaluate the condition
  • 0
    💀💀💀💀
  • 0
    Believe me or not, but that's what my colleagues from Morocco do on a daily basis.
  • 0
    *twitch*
  • 0
    if (isChecked)
    isChecked = false;

    //GENIUS
  • 0
    There is an use case where this will make sense, but if you have to do that then you are better of refactoring your whole code.

    Imagine if isEnabled can be true, or 1 or any other truthy value. This way you are ensuring that isEnabled must be boolean and true. True, this is stupid. But works I guess 😊
  • 1
    This one comes with strings attached
  • 0
    @ironyinabox @Cod-eLurkin Cause it's supposed to be a boolean and he wrote "true" as string instead True like it was supposed to. Boolean is supposed to be in True and False
  • 0
  • 0
    It should clearly be..

    if ("true".equals(isEnabled.toString)){ ... }

    ;)
  • 0
    what im feeling rn
Add Comment