[#35592] String#center — Take_tk <ggb03124@...>

 仕様拡張のお願い。と言うほどのものでもないですが・・

33 messages 2002/07/20
[#35593] Re: String#center — Kazuhiro NISHIYAMA <zn@...> 2002/07/20

西山和広です。

[#35596] Re: String#center — Take_tk <ggb03124@...> 2002/07/20

たけ(tk)です。

[#35597] Re: String#center — Kazuhiro NISHIYAMA <zn@...> 2002/07/20

西山和広です。

[#35599] Rational#to_int ← String#center — Take_tk <ggb03124@...> 2002/07/21

たけ(tk)です。

[#35601] Re: Rational#to_int ← String#center — matz@... (Yukihiro Matsumoto) 2002/07/21

まつもと ゆきひろです

[#35618] new mathn [Re: Rational#to_int ← String#center] — keiju@... (石塚圭樹) 2002/07/23

けいじゅ@日本ラショナルソフトウェアです.

[#35624] Re: new mathn [Re: Rational#to_int ← String#center] — matz@... (Yukihiro Matsumoto) 2002/07/24

まつもと ゆきひろです

[#35628] Re: new mathn [Re: Rational#to_int ← String#center] — keiju@... (石塚圭樹) 2002/07/24

けいじゅ@日本ラショナルソフトウェアです.

[#35630] Re: new mathn [Re: Rational#to_int ← String#center] — matz@... (Yukihiro Matsumoto) 2002/07/24

まつもと ゆきひろです

[ruby-list:35624] Re: new mathn [Re: Rational#to_int ← String#center]

From: matz@... (Yukihiro Matsumoto)
Date: 2002-07-24 02:39:04 UTC
List: ruby-list #35624
まつもと ゆきひろです

In message "[ruby-list:35618] new mathn [Re: Rational#to_int ← String#center]"
    on 02/07/23, 石塚圭樹 <keiju@rational.com> writes:

|これを使うとmathnは以下のように使えるようになります.
|
|require "other"
|
|1/2 #=> Rational(1,2)
|Mathn::NormalBehavior.scope_in do
|  # このブロックの中では通常のRubyの振る舞い
|  1/2 #=> 0
|  other_obj.message
|  Mathn::MathnBehavior.scope_in do
|    # このブロックの中では通常のMathnの振る舞い
|    1/2 #=> Rational(1,2)
|    other_obj.message
|  end
|end

どのように実現するかはともかく、Perlの use integer のような
文法で指定できるとよいでしょうね。個人的には以下のようなのを
夢想してます。

def foo(a,b)
  a/b
end


def bar(a,b)
  use DivFloat
  a/b
end

use DivRat

a = 1
b = 2

a/b # => Rational(1,2)
foo # => 0
bar # => 0.5

問題はどのように意味づけするかですが...

                                まつもと ゆきひろ /:|)

In This Thread