Created
February 4, 2018 02:39
-
-
Save sachin21/4085cc9dfee12ae3356f1d73a034b9e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[14] pry(main)> 1.0.step(2, 0.1).to_a | |
=> [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7000000000000002, 1.8, 1.9, 2.0] |
(11/10r).step(2, 1/10r).map(&:to_f)
# => [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]
Thanks for your answer!
It looks it is the best solution.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm. the answer is this?