Scala 中object和class的区别
2016-02-09 12:33
633 查看
Scala中没有静态类型,但是有有“伴侣对象”,起到类似的作用。
Scala中类对象中不可有静态变量和静态方法,但是提供了“伴侣对象”的功能:在和类的同一个文件中定义同名的Object对象:(须在同一文件中;main方法定义在Object对象中)
Scala中类对象中不可有静态变量和静态方法,但是提供了“伴侣对象”的功能:在和类的同一个文件中定义同名的Object对象:(须在同一文件中;main方法定义在Object对象中)
private[spark] class Client( val args: ClientArguments, val hadoopConf: Configuration, val sparkConf: SparkConf) extends Logging {...} object Client extends Logging { def main(argStrings: Array[String]) { if (!sys.props.contains("SPARK_SUBMIT")) { logWarning("WARNING: This client is deprecated and will be removed in a " + "future version of Spark. Use ./bin/spark-submit with \"--master yarn\"") } // Set an env variable indicating we are running in YARN mode. // Note that any env variable with the SPARK_ prefix gets propagated to all (remote) processes System.setProperty("SPARK_YARN_MODE", "true") val sparkConf = new SparkConf val args = new ClientArguments(argStrings, sparkConf) // to maintain backwards-compatibility if (!Utils.isDynamicAllocationEnabled(sparkConf)) { sparkConf.setIfMissing("spark.executor.instances", args.numExecutors.toString) } new Client(args, sparkConf).run() } ...... }
相关文章推荐
- NSGAIII中的normalization objectives
- (object sender, EventArgs e)中的sender 和e有什么用呀?
- Objective-C Runtime系统
- JS调试输出Object
- 线程和QObjects
- ZwQuerySymbolicLinkObject routine
- ZwOpenSymbolicLinkObject routine
- IOS学习第十一天 OC语言的学习 Objective-C简介
- 百度对象存储BOS(Baidu Object Storage)进行冷存储数据备份
- JavaScript菜鸟教程Object2
- Object-C--->Swift之(十一)属性观察者
- DRIVER_OBJECT
- FILE_OBJECT structure
- C++多继承的好处是增加了弹性和灵活性,Delphi类强迫单继承TObject是为了提供许多强大功能
- BO SDK - 列出所有 web intelligence 报表用到的 universe object
- json-lib中的JSONObject和JSONArray
- 原生 Base64编解码 Objective-C与Swift
- Enum-枚举的正确使用Objective-C
- Objective-C 【OC语法:不能修改 某个对象的 结构体属性的 成员】
- php中将SimpleXMLElement Object数组转化为普通数组