New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix description hash fetch #142
Fix description hash fetch #142
Conversation
|
||
Метод fetch принемает вторым параметром значение по умалчанию: | ||
То есть если мы запрашиваем значение по несуществующему ключу через метод `[]` (не забываем в Ruby - все есть объект и соответственно `[]` обычный метод объекта Hash), он молча возвращает `nil`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Скобки это зло) Вот полезняха https://ru.hexlet.io/courses/awesome-text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Скобки это зло) Вот полезняха https://ru.hexlet.io/courses/awesome-text
Спасибо за ссылку
Почему зло, потому что их содеожимое игнорируется?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Скобки указывают на то, что предложение составлено неверно. В хорошо составленных текстах скобки не нужны. Прогони текст через https://glvrd.ru/
https://maximilyahov.ru/blog/all/skobki/
В целом там и по другим частям текста тоже много всякого. Главный совет тут, читать книгу "пиши сокращай"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Прогнал текст через https://glvrd.ru/ и от корректировал
@mokevnin посмотришь изменения? |
@mokevnin ждём ревью: от скобок избавились, текст причесали |
@@ -2,45 +2,49 @@ | |||
|
|||
name: Метод fetch и извлечение значений из хеша | |||
theory: | | |||
|
|||
В Ruby помимо стандартного способа извлечения значения из хеша существует метод fetch. В чем же принципиальное отличие? | |||
В Ruby значения из hash по ключу извлекает метод `[]` и `fetch`. Посмотрим в чем отличие. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут нужно оставить вопрос.
Метод fetch принемает вторым параметром значение по умалчанию: | ||
Если запрашивать значение по несуществующему ключу, метод `[]` молча возвращает `nil`. | ||
|
||
Не забываем в Ruby - все объект и `[]` метод объекта Hash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот этот текст лучше переписать как обычное продолжение предыдущего без "не забываем", плюс тут нужно показать пример, то есть доказать то что мы говорим.
|
||
Не забываем в Ruby - все объект и `[]` метод объекта Hash. | ||
|
||
Метод `fetch` же действует иначе - если ключа нет, получим ошибку КеуError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Должен быть пример
|
||
Метод `fetch` же действует иначе - если ключа нет, получим ошибку КеуError | ||
|
||
Метод `fetch` принимает вторым параметром значение по умалчанию: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут нужно дописать текст, в котором раскрыть как это значение используется
puts env.fetch(:user, nil) # -> nil | ||
puts env.fetch(:user, 'guest') # -> 'guest' | ||
``` | ||
|
||
И даже блок или lambda: | ||
И даже блок или `lambda`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше по русски: лямбда-функция
``` | ||
Если переданного ключа нет в hash, вызываем блок, передав в него первым аргументом ключ, а вторым hash, иначе вернуть исходный hash. | ||
|
||
Сдесь понадобится метод `yield`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Орфографическая ошибка. Давайте текст еще через ворд прогоним
|
||
Сдесь понадобится метод `yield`. | ||
|
||
**[yield](https://apidock.com/ruby/Proc/yield)** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ссылки нужно либо прямо в тексте делать, либо выносить в tips
От корректировал @mokevnin посмотри пожалуста |
@mokevnin посмотри пожалуста |
@usernaimandrey можешь плз ребейзнуть и убрать мердж коммит? |
хорошо сделаю |
Закрыл этот пр т.к. напортачил с ребэйзом сделал другой |
No description provided.