[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...

Issue #10333 has been updated by Koichi Sasada.

9 messages 2014/10/07

[ruby-core:65904] [ruby-trunk - Feature #10426] A predicate to express congruence

From: mail@...
Date: 2014-10-26 02:16:40 UTC
List: ruby-core #65904
Issue #10426 has been updated by gogo tanaka.


@Tsuyoshi Sawada san
seems interesting.

Only one thing I'm a little worried about is `congruent?` might be too specified word.
I mean, I'm not sure `congruent` can be used in except modulo or geometry context.

----------------------------------------
Feature #10426: A predicate to express congruence
https://bugs.ruby-lang.org/issues/10426#change-49643

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
I occasionally felt the necessity of a predicate that checks congruence with respect to some operations:

~~~ruby
class Object
	def equal_by? other, &pr
		pr.call(self) == pr.call(other)
	end
	alias congruent? equal_by?
end

5.congruent?(2){|e| e % 3} #=> true
"HELLO".equal_by?("Hello", &:downcase) #=> true
~~~



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next