[#4766] Wiki — "Glen Stampoultzis" <trinexus@...>

21 messages 2000/09/04
[#4768] RE: Wiki — "NAKAMURA, Hiroshi" <nahi@...> 2000/09/04

Hi, Glen,

[#4783] Re: Wiki — Masatoshi SEKI <m_seki@...> 2000/09/04

[#4785] Re: Wiki — "NAKAMURA, Hiroshi" <nakahiro@...> 2000/09/05

Howdy,

[#4883] Re-binding a block — Dave Thomas <Dave@...>

16 messages 2000/09/12

[#4930] Perl 6 rumblings -- RFC 225 (v1) Data: Superpositions — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/09/15

[#4936] Ruby Book Eng. translation editor's questions — Jon Babcock <jon@...>

20 messages 2000/09/16

[#5045] Proposal: Add constants to Math — Robert Feldt <feldt@...>

15 messages 2000/09/21

[#5077] Crazy idea? infix method calls — hal9000@...

This is a generalization of the "in" operator idea which I

17 messages 2000/09/22

[#5157] Compile Problem with 1.6.1 — Scott Billings <aerogems@...>

When I try to compile Ruby 1.6.1, I get the following error:

15 messages 2000/09/27

[ruby-talk:5172] Re: Types and ===

From: kjana@... (YANAGAWA Kazuhisa)
Date: 2000-09-28 12:13:52 UTC
List: ruby-talk #5172
In message <004e01c028ee$da999680$01f9fea9@austin.rr.com>
hal9000@hypermetrics.com writes:

> 1. Why do we say "case other; when receiver" and not
> "case receiver; when other"?

Because we want to test some variable is in some container, in range,
mathes some pattern and so on....  So the variable to be tested is
naturally placed at the `position at which parameter occur'.

For example:

    def daysuffix(day)
      case day
      when 4..20, 24..30
        "th"
      when 1, 21, 31
        "st"
      when 2, 22
        "nd"
      when 3, 23
        "rd"
      end
    end

`day' is variable.  Of course this code expect 1 <= day <= 31.  Here
we want to test where `day' fits.

# Of course, more effective and natural code is available :-P


> 2. Why is the argument order for pattern === string opposite
> from the order for string =~ pattern?

# There is Regexp#=~ so you can write patter =~ string.

Standing on the basis above, `===' --- is NOT an equality operator ---
in `when' clauses should test what the variable is for objects on a
clause.  Therefore Regexp#=== is defined as Regexp#=~, Range#=== as
Range#include?, Class#=== tests the argument's class is subclass of
self, etc. etc....


> It almost (I'm not serious here, not entirely) makes me want to propose
> two more operators ==> and <== which point to the receiver... then
> the === could be used for symmetrical cases.

Operator `===' is not commutative from its standing basis.  It IS an
merely symbol which points methods called on when clauses.


-- 
kjana@os.xaxon.ne.jp                             September 28, 2000
It is comparison that makes men happy or miserable.

In This Thread