Skip to content

Instantly share code, notes, and snippets.

@pedrofurla
Created October 23, 2016 18:07
Show Gist options
  • Save pedrofurla/d48d1f1fc759e2849400cb91fc69695b to your computer and use it in GitHub Desktop.
Save pedrofurla/d48d1f1fc759e2849400cb91fc69695b to your computer and use it in GitHub Desktop.
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40).
Type in expressions for evaluation. Or try :help.
scala> :paste
// Entering paste mode (ctrl-D to finish)
object A {
object B {
def foo: Int = 4
}
class B {}
def bar: Int = 5
}
class A {}
// Exiting paste mode, now interpreting.
defined object A
defined class A
scala> classOf[A].getMethods.map(_.getName).mkString("\n")
res1: String =
wait
wait
wait
equals
toString
hashCode
getClass
notify
notifyAll
scala> classOf[A.type].getMethods.map(_.getName).mkString("\n")
<console>:13: error: class type required but A.type found
classOf[A.type].getMethods.map(_.getName).mkString("\n")
^
scala> A
res3: A.type = A$@3af85921
scala> A.getClass.getMethods.map(_.getName).mkString("\n")
res4: String =
bar
wait
wait
wait
equals
toString
hashCode
getClass
notify
notifyAll
scala> A.B.getClass.getMethods.map(_.getName).mkString("\n")
res5: String =
foo
wait
wait
wait
equals
toString
hashCode
getClass
notify
notifyAll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment