Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Python, a function that makes and returns a copy would be idiomatically named shuffled(). Consider sorting:

   xs.sort()        # in-place
   ys = sorted(xs)  # copy
As for functions returning the object - I think it's a hack around the absence of direct support for such repetition in the language itself. E.g. in Object Pascal, you'd write:

   with array do
   begin
      append(A);
      append(B);
      sort;
   end;
Or better yet, in Smalltalk:

   array append(A); append(B); sort.
https://en.wikipedia.org/wiki/Method_cascading





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: