Conversation
|
тесты в ci не прошли, нужно поправить |
test/bukanin/arrays/solution.rb
Outdated
| right = array.size | ||
| left = 0 | ||
|
|
||
| loop do |
There was a problem hiding this comment.
переписываем на рекурсию
test/bukanin/fp/solution.rb
Outdated
| sumstat = 0.0 | ||
| counted = 0 | ||
|
|
||
| for idx in 0..(array.size - 1) |
There was a problem hiding this comment.
постарайся не использовать for, в реальной жизни он крайне редко используется. тут задачи скорее на map/reduce, можно смело использовать любые стандартные функции из арсенала массива
https://github.com/bbatsov/ruby-style-guide#no-for-loops
test/bukanin/fp/solution.rb
Outdated
| def chars_count(films, threshold) | ||
| counted = 0 | ||
|
|
||
| for idx in 0..(films.size - 1) |
There was a problem hiding this comment.
тут тоже for нужно заменить
| for elem in self | ||
| yield(elem) | ||
| end | ||
| self |
There was a problem hiding this comment.
что вернется в конце функции если не написать тут self?
| # Написать свою функцию my_map | ||
| def my_map | ||
| result = MyArray.new | ||
| my_each do |elem| |
There was a problem hiding this comment.
test/bukanin/fp2/solution.rb
Outdated
| def my_map | ||
| result = MyArray.new | ||
| my_each do |elem| | ||
| result.append(yield(elem)) |
There was a problem hiding this comment.
не припомню метод append у массива
|
|
||
| def test_my_compact | ||
| func = -> (element) { element if element.even? } | ||
| func_another = -> (element) { element * @int } |
There was a problem hiding this comment.
добавь ещё вот такой assert
func_yet_another = -> (element) { element.even? }
assert @array.map(&func_yet_another).compact == @my_array.my_map(&func_yet_another).my_compactThere was a problem hiding this comment.
Тест не проходит потому что из my_each возвращаются Enumerator'ы с одинаковыми элементами, но разными адресами в памяти
No description provided.