-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs: add an example to -Yindent-colons
section
#10534
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
As discussed on gitter, for the record, here is a counter example. extension (src : => Unit) def ==> (dst : => Unit) : Unit = ()
locally {
println("hi")
} ==>
locally {
println("there")
} There is no option to do so with indentation only. |
@soronpo you can do this: locally:
println("hi")
.==> :
println("there") |
@SethTisue I don't think the example you gave is a good one, as you can just write: val dinner =
val s1 = "fish"
val s2 = "chips"
List(s1, s2) instead of: val dinner = locally:
val s1 = "fish"
val s2 = "chips"
List(s1, s2) |
@LPTK well, dang. I thought I'd tried that? okay, I'll take a second look at the places in my codebase I thought I needed |
better example now |
@SethTisue but you can just write this: credentials ++ :
val file = Path.userHome / ".credentials"
if file.exists
then Seq(Credentials(file))
else Seq() 😄 |
locally
in -Yindent-colons
section-Yindent-colons
section
okay, so the remaining use case is this kind of thing:
which seems too niche to even cover, so I've revised this not to mention or use my real mission here was to get my questions about |
Yes, I think the only use for |
@LPTK I think the following wording in the doc:
misled me; I read “function argument” as referring specifically to lambdas & by-names. I have amended this PR to omit the word “function” there |
@SethTisue Ah yes, it's an English language ambiguity. I think the meaning originally intended by "enclosing a function argument" was "enclosing the argument to a function", not "enclosing a function passed as an argument". It could be misleading indeed! |
Discussion has settled down and this is ready for merge, I believe. |
At least, I think this is the recommendation....... is it?
I admit this came up when I was intentionally expunging all braces from a repo of mine as an exercise, in an attempt to form an opinion on the future of
-Yindent-colons
never using braces could be a pointless exercise, or it could be good pedagogically actually. it's simpler for learning if the answer to "do I ever actually need braces?" is "no"
in any case, I like knowing I have the option with
locally