Ad
  • Custom User Avatar

    I really like this solution as it is really simple to read and understand.

  • Custom User Avatar

    Arguments are only mutated if you mutate it like you mutate objects. Reassigning values is like calling a different thing the same name, it does not mutate anything so it's perfectly fine.

    Unless you're intentionally using optional arguments as replacement of var, in which case that would actually make things less readable ;-)

  • Custom User Avatar

    I am fully aware of this technical aspect. But doesn't this procedure break a readabilty? I am a comming from a assumption that argument is 'immutable' inside a method, and if we want to acces anything from it, just create a specific variable or access it directly.
    Just my thoughts

  • Custom User Avatar

    It doesn't change any references. You're thinking of something else which only happens with languages with explicit pointers (e.g C and C++).

  • Custom User Avatar

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