4 ms·
first Returns the first element in the array and terminated the chain second Returns the second element in the array and terminated the chain third Returns th
by GuiA 12y ago
first Returns the first element in the array and terminated the chain
second Returns the second element in the array and terminated the chain
third Returns the third element in the array and terminated the chain
fourth Returns the fourth element in the array and terminated the chain
fifth Returns the fifth element in the array and terminated the chain
sixth Returns the sixth element in the array and terminated the chain
seventh Returns the seventh element in the array and terminated the chain
eighth Returns the eighth element in the array and terminated the chain
ninth Returns the ninth element in the array and terminated the chain
tenth Returns the tenth element in the array and terminated the chain
... is this a joke?
- agp2572 12y agoIs Rail's ActiveSupport a joke? https://github.com/rails/rails/blob/a31277011814b7bdb6be41a807e14d6bf2852620/activesupport/lib/active_support/core_ext/array/access.rb#L57 https://github.com/rails/rails/blob/a31277011814b7bdb6be41a8...
- p4lindromica 12y agoI think the specific example you gave actually is a joke. http://www.quora.com/Why-is-Array-forty_two-called-the-reddit-in-Ruby-on-Rails http://www.quora.com/Why-is-Array-forty_two-called-the-reddi...
- ankurpatel 12y agoYes it is :)
- Karunamon 12y agoNot really, it's just a way to make your code more expressive in a different way, I can see it helping in some cases since arrays are zero-indexed. arr.first is more immediately expressive to me than arr[0] - but this is a matter of opinion :)
- sanderjd 12y agoIt's pretty interesting to compare the extent to which different libraries take this idea. I think tenth is the furthest I've seen. I find first and last useful frequently, but I think the furthest of these ordinals I've ever used in real code was second or maybe third.
- dxbydt 12y agohttps://github.com/scala/scala/blob/v2.11.1/src/library/scala/Product22.scala https://github.com/scala/scala/blob/v2.11.1/src/library/scal...
- SoftwareMaven 12y agoQuite common, actually. Check out the Racket list documentation[1] or the Common Lisp list docs[2], for example. 1. http://docs.racket-lang.org/reference/pairs.html http://docs.racket-lang.org/reference/pairs.html 2. http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node149.html http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node149.html