Skip to content

Instantly share code, notes, and snippets.

@SethTisue
Created March 28, 2016 19:55
Show Gist options
  • Save SethTisue/332af8d6ac48c57deb9f to your computer and use it in GitHub Desktop.
Save SethTisue/332af8d6ac48c57deb9f to your computer and use it in GitHub Desktop.
scala> import scala.language.reflectiveCalls
import scala.language.reflectiveCalls
scala> type Structural = { def foo: Int; def foo_=(x: Int): Unit }
defined type alias Structural
scala> object O { var foo = 5 }
defined object O
scala> (O: Any).asInstanceOf[Structural].foo = 10
(O: Any).asInstanceOf[Structural].foo: Int = 10
scala> O.foo
res0: Int = 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment