【文件属性】:
文件名称:necklace:用于 ruby 的 Clojure 线程宏
文件大小:7KB
文件格式:ZIP
更新时间:2021-06-14 09:08:03
Ruby
项链
什么为什么
从 Clojure 移植->宏以使 Enumerable 的长链更具可读性
通常在 ruby 中链接方法调用时,方法的名称是描述性的,并且链是可读的。 (请注意,这可能违反了得墨忒耳定律,但这只是一个示例)。 人们可以想象这样的事情
food_processor . add ( vinegar )
. add ( garlic )
. add ( pepper )
. start
. drizzle ( oil )
每个方法返回self并且链描述操作。
但是,使用 Enumerable 时,由于方法更抽象,因此在链接操作时通常会牺牲可读性:
[ 1 , 3 , 5 , 7 , 9 ] . map do | n |
n + 1
end . map
【文件预览】:
necklace-master
----.gitignore(588B)
----README.md(4KB)
----Gemfile(106B)
----Gemfile.lock(912B)
----necklace.gemspec(886B)
----spec()
--------through_spec.rb(2KB)
--------through_last_spec.rb(1KB)
--------through_first_spec.rb(1KB)
--------spec_helper.rb(363B)
----VERSION(6B)
----lib()
--------necklace.rb(580B)
----Rakefile(252B)