定义一个隐式转换函数,dzhdouble2int,将double转换为int,这样编译器搜索到了从double到int的隐式转换,不再报错。
隐式转换在spark运用广泛,如implicit def rddtopairrddfunction等
C:\Users\admin>scala Welcome to Scala version 2.10.4 (Java HotSpot(TM) Client VM, Java 1.7.0_13). Type in expressions to have them evaluated. Type :help for more information.
scala> val i:int=3.5 :7: error: not found: type int val i:int=3.5 ^
scala> val i:Int=3.5 :7: error: type mismatch; found : Double(3.5) required: Int val i:Int=3.5 ^
scala> implicit def dzhdouble2int (x:Double)=x.toInt warning: there were 1 feature warning(s); re-run with -feature for details dzhdouble2int: (x: Double)Int
scala> val i:Int=3.5 i: Int = 3
scala>
- 计算机视觉系列 -MMDetection 之MobileNetV2YOLOV3 经典算法(一)
- Rasa 3.x 学习系列- Rasa - Issues 4635:Make Rasa X model pull interval configurable in local mode
- Rasa 3.x 学习系列- Rasa - Issues 4759:Training Luis data with luis_schema_version higher than 4.x.x will
- Rasa 3.x 学习系列- Rasa - Issues 4799 rasa interactive does not work without nlu data
- Rasa 3.x 学习系列- Rasa - Issues 4917 Support S3 namespaces when retrieving models from buckets
- Rasa 3.x 学习系列- Rasa - Issues 4925 “rasa init” will ask if user wants to train a model
- Rasa 3.x 学习系列- Rasa - Issues 4985 Fix errors during training in ResponseSelector学习笔记
- Rasa 3.x 学习系列- Rasa - Issues 4933 Improved error message that appears when an incorrect paramete学习笔记
- Rasa 3.x 学习系列- Rasa - Issues 4792 socket debug logs clog up debug feed学习笔记
- Rasa 3.x 学习系列- Rasa - Issues 4873 dispatcher.utter_message 学习笔记