TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Piping with Swift

23 点作者 mseri将近 11 年前

2 条评论

mercurial将近 11 年前
I'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将近 11 年前
I don&#x27;t get it, why do I need the pipe operator for this?<p><pre><code> #(9 1 2 3 7 5 5 8 4) unique sorted -&gt; ( 1,2,3,4,5,7,8,9) </code></pre> In Objective-Smalltalk (<a href="http://objective.st" rel="nofollow">http:&#x2F;&#x2F;objective.st</a>).<p>Definitions:<p><pre><code> -unique { (NSOrderedSet orderedSetWithArray:self) array. } -sort { self sortedArrayUsingSelector:&#x27;compare:&#x27;. } </code></pre> Why is it suddenly cool to make things so much more complicated than they need to be?