3 ms·
Piping with Swift
- mercurial 12y agoI'm a bit torn about normal functions. Traits/typeclasses often make more sense, but on the other hand, this kind of static monkey-patching makes it difficult to figure out which trait provides which method when looking at the code. But without something like the operator proposed here, chaining normal functions is quite awkward.
- mpweiher 12y agoI don't get it, why do I need the pipe operator for this? #(9 1 2 3 7 5 5 8 4) unique sorted -> ( 1,2,3,4,5,7,8,9) In Objective-Smalltalk (http://objective.st http://objective.st). Definitions: -unique { (NSOrderedSet orderedSetWithArray:self) array. } -sort { self sortedArrayUsingSelector:'compare:'. } Why is it suddenly cool to make things so much more complicated than they need to be?