https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112020-05-17T17:54:13ZRuby Issue Tracking SystemRuby master - Feature #16899: Add method `Array#both_end`https://bugs.ruby-lang.org/issues/16899?journal_id=856812020-05-17T17:54:13Zshan (Shannon Skipper)
<ul></ul><p>I think #both_ends reads better in the plural form. Or #first_last harkens to #min_max and is unambiguous. Other options might be #extremes or #bookends.</p>
<p>I'd vote #first_last.</p> Ruby master - Feature #16899: Add method `Array#both_end`https://bugs.ruby-lang.org/issues/16899?journal_id=856832020-05-17T18:33:23Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I think #first_last would be a better name as well; primary reason being that we<br>
already have #first and #last.</p>
<p>I am also ok with the proposal itself, although I think I have not had a need to<br>
use this often. But I don't mind such a method existing.</p>
<p>#extremes is a bit of a strange name though. It reminds me of mathematics.</p>
<p>#bookends for some reason reminds me of a bookworm - no idea why. :)</p>
<p>#both_end and #both_ends are a bit strange as names. I think one problem here<br>
is that the name implies "ends", but we also have #first and #last, and I am<br>
not sure if both first, and last, can be considered as two ends? What about<br>
circular arrays? :P</p>
<p>So I think #first_last would be a better name. (A single name might be better<br>
but it is harder to find a goot name there.)</p> Ruby master - Feature #16899: Add method `Array#both_end`https://bugs.ruby-lang.org/issues/16899?journal_id=856852020-05-17T19:03:31Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Subject</strong> changed from <i>Proposal: Add Array#both_end method</i> to <i>Add method `Array#both_end`</i></li><li><strong>Description</strong> updated (<a title="View differences" href="/journals/85685/diff?detail_id=57070">diff</a>)</li></ul> Ruby master - Feature #16899: Add method `Array#both_end`https://bugs.ruby-lang.org/issues/16899?journal_id=856862020-05-17T21:21:48ZDan0042 (Daniel DeLorme)
<ul></ul><p>I think <code>ary.values_at(0,-1)</code> does the job pretty well.</p> Ruby master - Feature #16899: Add method `Array#both_end`https://bugs.ruby-lang.org/issues/16899?journal_id=856912020-05-18T00:59:49Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>Why not start as a gem? There are things not possible without core changes, but it seems this requested feature needs no such things.</p> Ruby master - Feature #16899: Add method `Array#both_end`https://bugs.ruby-lang.org/issues/16899?journal_id=856932020-05-18T01:44:08ZS_H_ (Shun Hiraoka)gamelinks007@gmail.com
<ul></ul><p>Thanks for feedbacks.</p>
<p>shan (Shannon Skipper) wrote in <a href="#note-1">#note-1</a>:</p>
<blockquote>
<p>I think #both_ends reads better in the plural form. Or #first_last harkens to #min_max and is unambiguous. Other options might be #extremes or #bookends.</p>
<p>I'd vote #first_last.</p>
</blockquote>
<p>shevegen (Robert A. Heiler) wrote in <a href="#note-2">#note-2</a>:</p>
<blockquote>
<p>I think #first_last would be a better name as well; primary reason being that we<br>
already have #first and #last.</p>
<p>I am also ok with the proposal itself, although I think I have not had a need to<br>
use this often. But I don't mind such a method existing.</p>
<p>#extremes is a bit of a strange name though. It reminds me of mathematics.</p>
<p>#bookends for some reason reminds me of a bookworm - no idea why. :)</p>
<p>#both_end and #both_ends are a bit strange as names. I think one problem here<br>
is that the name implies "ends", but we also have #first and #last, and I am<br>
not sure if both first, and last, can be considered as two ends? What about<br>
circular arrays? :P</p>
<p>So I think #first_last would be a better name. (A single name might be better<br>
but it is harder to find a goot name there.)</p>
</blockquote>
<p>#first_last is good name. I use this name.</p>
<p>shyouhei (Shyouhei Urabe) wrote in <a href="#note-5">#note-5</a>:</p>
<blockquote>
<p>Why not start as a gem? There are things not possible without core changes, but it seems this requested feature needs no such things.</p>
</blockquote>
<p>OK, I'll started create gem to Array#first_last and other useful methods implmented.</p>
<p>Thanks.</p>