Skip to content

Document using parameters on classes can provide given instances #10882

Closed
@bishabosha

Description

@bishabosha

We should probably document that using clauses with parameters annotated val/var generate a given instance in their body (this is obvious for Scala 2 users, but maybe not for someone who has only ever seen the new syntax, where using may have been understood as only a "consumer" of given instances)

Minimized example

class GivenIntBox(using val givenInt: Int)

@main def test =
  val b = GivenIntBox(using 23)

  import b.given

  println(summon[Int])

Output

23

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions