LoginSignup
2
0

More than 5 years have passed since last update.

Rubyで整数の切り捨てをしたい

Last updated at Posted at 2018-03-05
floor.rb
#引数にマイナスを取ればOK
222.floor(-2)

もし下のようなエラーが出たら

wrong number of arguments (1 for 0)
Rubyのバージョンが低いかもしれません。

# 自分の環境
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]

どうやらfloorが引数をとれるのは2.4.0からみたいです。
https://docs.ruby-lang.org/ja/search/query:Float%23floor/type:instance-method/

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0