So I am trying to solve a class problem/homework on repl.it, in ruby, and this is the error listing I'm given.
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
undefined method `filter' for [{:r=>1, :c=>0}, {:r=>0, :c=>1}]:Array
(repl):61:in `escape'
(repl):79:in `maze_escape'
(repl):82:in `<main>'
I can't understand the reason for this, because filter is clearly a method that is defined for the class Array, as a part of Ruby core, Here
You are using ruby version 2.5.5
.
Array#filter
was added to ruby version 2.6.0
.
However, the method is merely an alias for Array#select
- so you can use this instead, if you are unable to upgrade the ruby version right now.
Note: The documentation you linked to is for ruby version 2.6.3
(i.e. the latest, at the time of writing). You can see the (almost-identical) documentation for version 2.5.5
here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With