在python中, 可以通过"type(instants)"去判断类型.
scala中, 判断一个数据或者对象的类型只需要在该对象后面添加 .getClass.getSimpleName
scala> 222.getClass.getSimpleName
res1: String = int
scala> "222".getClass.getSimpleName
res2: String = String

222.getClass.getSimpleNameres1: String = intscala> "222".getClass.getSimpleNameres2: ..._s"> 222.getClass.getSimpleNameres1: String = intscala> "222".getClass.getSimpleNameres2: ..."> 222.getClass.getSimpleNameres1: String = intscala> "">
在python中, 可以通过"type(instants)"去判断类型.
scala中, 判断一个数据或者对象的类型只需要在该对象后面添加 .getClass.getSimpleName
scala> 222.getClass.getSimpleName
res1: String = int
scala> "222".getClass.getSimpleName
res2: String = String


被折叠的 条评论
为什么被折叠?
