78
Comments
  • 0
    If done correctly, that should be possible.
    In many langs the number gets converted to a string (regardless of orientation!) and classes can ocerwrite se sort of to-string method that gets called upon concatination with another string.
  • 1
    @LinusCDE No that shouldn't be possible because it's stupid and leads to errors. Ask the javascript sort function if you want an example
  • 3
    @12bitfloat Well I excluded JS because of that.
    Other static programming languages (Java, C#,...) give you both benefits.

    JS having two results based on the order of operands (""+1 vs 1+"") is just ridiculus.
  • 2
    JS?

    "" == false
    [] == false
    0 == false

    but

    "" != [] != 0
  • 0
    @12bitfloat @LinusCDE the key is what you are doing with the result. If you are putting them into a string, then whatever, if you want the sqrt of "Y" + 0 then you have complications. If you are scared by this functionality you should use a statically or strongly typed language.
  • 0
    @river226 If you want to run sqrt("Y" + 0) then you'll have the same problems since sqrt will receive the calculated result of "Y" + 0 and will need to act accordingly (or don't work at all in statically typed langs which is why I love those over dynamic ones).
  • 0
    @LinusCDE yeah... Hence the complications.
  • 0
    @river226 I'm also scared of bad smells and disgusting food. Maybe has something in common
  • 0
    @12bitfloat well the problem is that "Y" + 0 + "L" + 0 is valid syntax in most static languages. As far as disgust I have noticed it depends on where you come from much like food.
  • 0
    @river226 LinusCDE was talking about weak typing. Numeric to string type coercion is about as much weak typing as is desirable
  • 0
    I'm working on a yolo project my self. Yolo is awesome. That a camel, that's a bird, that's a bike.

    Fucking amazing 😁👍
  • 0
    Ruby: duck type that shit if you want. As with everything
  • 0
    @Sumafu the list of values you posted are falsy. Not false. Use === instead of ==.
  • 0
    @olback I just hate the === operator. I forget it every time and only my IDE reminds me of it 😅
  • 1
    @Sumafu I agree. == should really act like ===. And sure, JS is just plain weird sometimes.
Add Comment