Project

General

Profile

Bug #17114

Updated by sawa (Tsuyoshi Sawada) over 1 year ago

Hello dear ruby community, 
 I observed the following behaviour: strange behaviour (maybe it is intended) in Version 2.6.3p62: 
 ruby -v 
 ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] 

 In pry I can see: 
 ``` ruby 
 [7] pry(main)> 1.0.floor +1 # 
 => 1.0 
 [8] pry(main)> (1.0).floor +1 # 
 => 1.0 
 [9] pry(main)> (1.0.floor) +1 # 
 => 2 
 [10] pry(main)> 1.0.floor + 1 # 
 => 2 
 ``` 

 
 I think this the reason is, that +1 is due to `+1` being taken as an argument to `floor`. It floor. Anyway, it is strange strange, that `1.0.floor` 1.0.floor is an integer but `1.0.floor +1` is 1.0.floor +1 again a float. Is this intended behaviour? behaviour. I do have not have the latest lates ruby version installed, so I do not know if it has been may be changed. Also I observed it only with `+1`. +1. With `-1`, -1 I get: 

 
 ``` ruby 
 [8] pry(main)> 1.0.floor -1 # 
 => 0 
 ``` 


 Best regards, 
 Tammo 
 



Back