Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
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.
Technically, it's more like passing by a const reference and rebinding the reference.
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
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 ;-)
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.
Not for primitive types as they're always passed by value.
This one modifies the input variable. Isn't that considered bad practice?