問題:
I am working through a book which gives examples of Ranges being converted to equivalent arrays using their "to_a" methods我正在閱讀一本書,其中給出了使用“to_a”方法將範圍轉換爲等效數組的示例
When i run the code in irb I get the following warning當我在 irb 中運行代碼時,我收到以下警告
warning: default `to_a' will be obsolete
What is the the correct alternative to using to_a?使用 to_a 的正確替代方法是什麼?
are there alternate ways to populate an array with a Range?有沒有其他方法可以用 Range 填充數組?
解決方案:
參考一: https://en.stackoom.com/question/nlx參考二: https://stackoom.com/question/nlx