Skip to content

Conversation

@rwjblue
Copy link

@rwjblue rwjblue commented Sep 7, 2023

This change does two main things:

  1. Indicate that (for_expression)'s introduce a @local.scope (this is the scope for the enumerators to be used within the loop).
  2. Indicate that the (identifiers) within the (enumerators) are @local.definitions.

For the following example snippet:

val fruits = List("apple", "banana", "avocado", "papaya")

val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))

for ((count, fruits) <- countsToFruits) {
  println(s"with (fruits) 'a' × $count = $fruits")
}

The count and fruits identifiers are new definitions introduced by the for expressions scope.

This change does two main things:

1. Indicate that `(for_expression)`'s introduce a `@local.scope` (this
   is the scope for the enumerators to be used within the loop).
2. Indicate that the `(identifiers)` within the `(enumerators)` are
   `@local.definition`s.

---

For the following example snippet:

```scala
val fruits = List("apple", "banana", "avocado", "papaya")

val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))

for ((count, fruits) <- countsToFruits) {
  println(s"with (fruits) 'a' × $count = $fruits")
}
```

The `count` and `fruits` identifiers are new definitions introduced by
the `for` expressions scope.
Copy link
Collaborator

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

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

Hey @rwjblue, same comment as the other PR. Would you be willing to add in some tests in the highlight queries showing this?

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