Skip to content

Conversation

travissarles
Copy link
Contributor

No description provided.

@travissarles travissarles mentioned this pull request Mar 30, 2017
33 tasks
val userBase = List(new User("Travis", 28),
new User("Kelly", 33),
new User("Jennifer", 44),
new User("Dennis", 23))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the style of indentation in parens varies widely, I'm not sure this one is a good one for a tutorial since we don't do trailing braces in Scala, generally, and trailing parens aren't that different from trailing braces. I'd format it as

val userBase = List(
  new User("Travis", 28),
  ...
  new User("Dennis", 23)
)

def foo(n: Int, v: Int) =
for (i <- 0 until n;
j <- i until n if i + j == v)
yield (i, j)
Copy link

@Ichoran Ichoran May 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'm not sure this is the best style to promote as it invites confusion about the comprehension part and the yield part. You don't indent the else farther than the corresponding if, so I'd tend to

for (...)
yield (i, j)

or

for (
  ...
)
yield (i, j)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it looks nicer but all of the examples in Odersky's book use an indent as does IntelliJ.

@travissarles travissarles merged commit e3f3041 into scala:master May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants