-
Notifications
You must be signed in to change notification settings - Fork 1k
Compare Scala 2 vs Scala 3 with tabs in Tour of Scala / Basics #2458
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
Conversation
_tour/basics.md
Outdated
{% scalafiddle %} | ||
{% tabs get-square-string class=tabs-scala-version %} | ||
|
||
{% tab 'Scala 2' for=get-square-string %} | ||
```scala mdoc | ||
def getSquareString(input: Double): String = { | ||
val square = input * input | ||
square.toString | ||
} | ||
println(getSquareString(2.5)) // 6.25 | ||
``` | ||
{% endscalafiddle %} | ||
{% endtab %} | ||
|
||
{% tab 'Scala 3' for=get-square-string %} | ||
```scala | ||
def getSquareString(input: Double): String = | ||
val square = input * input | ||
square.toString | ||
|
||
println(getSquareString(2.5)) // 6.25 | ||
``` | ||
{% endtab %} | ||
|
||
{% endtabs %} |
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.
We had a discussion about whether it is worth showing two tabs for a difference of a couple of braces. I wonder if the other website maintainers have an opinion about that? Should we keep showing just one code example (with braces, so that it compiles with both Scala 2 and Scala 3), or should we highlight this difference between Scala 2 and Scala 3 by showing those separate tabs?
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.
Maybe @SethTisue you have an opinion?
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.
Well, I believe we need some solution here. I don't think it's acceptable for it to be unclear to the reader whether some code is Scala 2 code, or Scala 3 code, or some code that has been carefully made to work on either.
The two basic possible solutions are:
- have separate Scala 2 and 3 versions of some pages
- have a single version, but use code tabs
It sounds like in this case it's already decided that we don't want to have separate 2 and 3 versions of the entire page. In that case, I think we should do the tabs.
There is some value in the freedom this gives us to, for example, omit braces from the Scala 3 version. But as I see it, the primary value, the main reason we ought to do this, is to be clear with the reader whether the code is Scala 2 or 3 or both. That's important to do even if the Scala 2 and 3 versions of the code are identical!
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.
Thank you for your feedback! We decided to not create tabs when the code snippets are identical, to remove some work. I hope this is fine too?
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.
Could it not have tabs, but still say something like "Scala 2 or 3"?
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.
We could add some banner to the code block to say it works in both?
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.
That's what I'm suggesting, yeah.
30f18d5
to
69ab6e2
Compare
I have also replaced some examples where the only difference is dropping the |
use scala 2 vs scala 3 tabs for tour/basics