How the get the classOf for a scala object type

前端 未结 3 1640
花落未央
花落未央 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:11

    Since Main is an object, for your example to work, simply replace your assignment line with;

    private [this] val TAG = this.getClass.getName;
    

提交回复
热议问题