From: Yukihiro Matsumoto Date: 2010-04-13T16:47:53+09:00 Subject: [ruby-dev:40970] Re: [Bug #3137] complex.rb changes exceptions of Math まつもと ゆきひろです In message "Re: [ruby-dev:40969] Re: [Bug #3137] complex.rb changes exceptions of Math" on Tue, 13 Apr 2010 16:30:38 +0900, keiju@ishitsuka.com (石塚圭樹) writes: |こんな感じです. "error"のところの例外をどうするかって話で, ここで | |>|> -e:1:in `atanh': can't convert nil into Float (TypeError) | |ちょっと分かりづらい例外かとおもったんですね. そうかなあ。そのまま、「real?がない」でいいんじゃないですかね。 |あと, | | def exp(z) | begin | if z.real? | exp!(z) | else | ere = exp!(z.real) | Complex(ere * cos!(z.imag), | ere * sin!(z.imag)) | end | rescue NoMethodError => exp | if exp.name == :real? | return exp(Float(z)) | end | raise | end | end | |はあるかなぁ... これは exp("1.1") なんてのを受け付けるようになっちゃうんで賛 成しません。