From: Clifford Heath Date: 2008-02-15T14:59:55+09:00 Subject: Cute open range? So I wanted to allow folk using my DSL to say "0..N", "1..N", etc, to describe the cardinality of a relationship, and I needed to find a useful way to define N without making it a fixed integer maximum value. Well, I came up with this, which I thought was cute: class N def self.coerce(n) [ n, n+1 ] # Anything you can do, I can do better end end Now when I ask (0..N) === m, for any m, it says "true", and when I say the following, it never ends: (0..N).each do |n| puts n end But more importantly, I can say: do_something if range.last == N Ruby is sweeet :-). Clifford Heath.