[#42643] メールのSMTP認証の方法(質問) — "Hisashi Yahata" <yahatah@...>

お世話になります。

34 messages 2006/08/09
[#42649] Re: メールのSMTP認証の方法(質問) — OHARA Shigeki <os@...> 2006/08/09

大原です。

[#42650] Re: メールのSMTP認証の方法(質問) — "Hisashi Yahata" <yahatah@...> 2006/08/09

大原様

[#42651] Re: メールのSMTP認証の方法(質問) — 植田裕之 <ueda@...> 2006/08/09

植田と申します。

[#42654] Re: メールのSMTP認証の方法(質問) — "Hisashi Yahata" <yahatah@...> 2006/08/09

植田 裕之様

[#42657] Re: メールのSMTP認証の方法(質問) — WATANABE Tetsuya <Tetsuya.WATANABE@...> 2006/08/09

渡辺哲也です。

[ruby-list:42695] Re: in演算子の提案

From: rubikitch <rubikitch@...>
Date: 2006-08-15 16:00:26 UTC
List: ruby-list #42695
From: <rubyist@morphball.net>
Subject: [ruby-list:42693] in演算子の提案
Date: Wed, 16 Aug 2006 00:51:11 +0900

るびきちです。

>   if s in [a, b, c]   # if [a, b, c].include?(s) と同義
> しかしinclude?メソッドを用いるときのみ、この順序は逆になります。
> 
> 
>   if [a, b, c].include?(s)
> 
> 
> 他の比較とは違って「比較条件」を先に、「変数」を後に書くことになり
> 私はこうした書き方に、少なからずストレスを感じます。

同感です。ぼくもつい s から書こうとしてしまいます。
こんなのはどうでしょうか?

require 'test/unit'

class Object
  def in(*args)
    if args.length == 1
      args[0].include? self
    else
      args.include? self
    end
  end
end

class TestIn < Test::Unit::TestCase
  def test_multiple_args
    assert_equal true,   1.in(1,2,3)
    assert_equal false, 10.in(1,2,3)
  end

  def test_array
    assert_equal true,   1.in([1,2,3])
    assert_equal false, 10.in([1,2,3])
  end
end

--
rubikitch
http://www.rubyist.net/~rubikitch/

In This Thread