[#44904] [ruby-trunk - Bug #5688][Open] Solaris10 で spawn を繰り返すとメモリリークする — okkez _ <redmine@...>

14 messages 2011/11/29

[ruby-dev:44793] [ruby-trunk - Feature #5549][Rejected] Comparable#min, Comparable#max

From: Yukihiro Matsumoto <matz@...>
Date: 2011-11-03 10:52:44 UTC
List: ruby-dev #44793
Issue #5549 has been updated by Yukihiro Matsumoto.

Status changed from Open to Rejected

なぜ、それが必要だと思いましたか?
この提案だと a.min(b) というスタイルになり、Enumerableの「もっとも小さい(大きい)要素を返す」という意味でなく、「ふたつの要素のうちより小さい(大きい)ものを返す」と記述しています。そのような記述のための語彙としてはmin,maxではなく、比較演算子 >, < を使うのだと思いますし、そのメソッドはすでにComparableに定義されています。
----------------------------------------
Feature #5549: Comparable#min, Comparable#max
http://redmine.ruby-lang.org/issues/5549

Author: Tsuyoshi Sawada
Status: Rejected
Priority: Normal
Assignee: 
Category: 
Target version: 


I request the following methods

    Comparable#min(other)
    Comparable#max(other)

which will work the same as

    [self, other].min
    [self, other].max

and can be defined as

    module Comparable
	def min other; [self, other].min end
	def max other; [self, other].max end
    end

Example use case: If you need to ensure that some calculated value becomes at least zero within a method chain.


-- 
http://redmine.ruby-lang.org

In This Thread