docs.scala-lang
docs.scala-lang copied to clipboard
two or three paragraphs seem missed in _overviews/scala3-book/taste-methods.md
After Line 131 in _overviews/scala3-book/taste-methods.md, there should be at least two paragraphs more.
Please could you describe more precisely what you mean? It doesn't appear to me that there is missing/deleted text. These two paragraphs are talking about the extension methods example snippet that immediately follows.
Do you mean that there is not enough text, and there should be more text dedicated to explaining other details about extension methods?
In Chinese version, file "_zh-cn/overviews/scala3-book/taste-methods.md" from line 154
如果没有IDE的帮助,那段代码可能很难阅读,但这个代码要明显得多:
{% tabs method_10 %} {% tab 'Scala 2 and 3' for=method_10 %}
engage( speedIsSet = true, directionIsSet = true, picardSaidMakeItSo = true, turnedOffParkingBrake = false ){% endtab %} {% endtabs %}
扩展方法
扩展方法 允许您向封闭类添加新方法。 例如,如果要将两个名为
hello和aloha的方法添加到String类中,请将它们声明为扩展方法:{% tabs extension0 %} {% tab 'Scala 3 Only' %}
extension (s: String) def hello: String = s"Hello, ${s.capitalize}!" def aloha: String = s"Aloha, ${s.capitalize}!" "world".hello // "Hello, World!" "friend".aloha // "Aloha, Friend!"{% endtab %} {% endtabs %}
But all these lines missed in English version.
ah this makes more sense, thanks!
An example of using extension methods has been added in the meantime.