Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    It doesn't appear your code is putting only distinct letters in new string. It seems all you're doing is combining the two strings, and sorting the new string.

  • Default User Avatar

    Technically, it's more like passing by a const reference and rebinding the reference.

  • Custom User Avatar

    Agreed again about understanding the difference between call by reference or call by value :) The point I tried to make was that in an dynamic language you should be careful about the assumption that the method input is indeed a primitive type.
    Not really an issue in code like this Kata of course. Unless somebody built a class that overloads & and >> :D

  • Custom User Avatar

    AFAIK functions in every dynamic language always receives a fresh value for primitive types. It only happens in the like of C/C++/C#/Rust via explicitly passed by reference (by &/ref), and they're the complete opposite of a dynamic language.

    It's nothing "extra careful", you should obtain the knowledge to know how they behave so you can put your effort on worrying about things that actually matter instead ;-)

  • Custom User Avatar

    Agreed that it doesn't affect the outer scope's value.
    However, I would argue that in a dynamically typed language, one should be extra careful about this.

  • Custom User Avatar

    Not for primitive types as they're always passed by value.

  • Custom User Avatar

    This one modifies the input variable. Isn't that considered bad practice?