How the get the classOf for a scala object type

前端 未结 3 1641
花落未央
花落未央 2020-12-28 11:25

I wonder how to get a class object for an object type in Scala. Ok, that is a mouth full because of the double meaning for object. So here an example which will fail:

<
3条回答
  •  感动是毒
    2020-12-28 12:05

    The reason why classOf[Main] doesn't work is because Main is not a type.

    Classes and traits define types, objects do not.

提交回复
热议问题