るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.022秒)
トップページ > バージョン:2.5.0[x] > クラス:Numeric[x] > クエリ:Rational[x] > クエリ:nonzero?[x]

別のキーワード

  1. _builtin rational
  2. rational **
  3. json/add/rational to_json
  4. json/add/rational json_create
  5. rational convert

ライブラリ

検索結果

Numeric#nonzero? -> self | nil (54415.0)

自身がゼロの時 nil を返し、非ゼロの時 self を返します。

...理をさせたい場合に以
下のように記述する事もできます。

//emlist[例][ruby]{
a = %w( z Bb bB bb BB a aA Aa AA A )
b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
//}

@see Numeric#zero?...