您的位置:首页 > 汽车 > 新车 > 找素材的网站大全_成都程序员培训机构_免费访问国外网站的app_市场营销专业就业方向

找素材的网站大全_成都程序员培训机构_免费访问国外网站的app_市场营销专业就业方向

2025/4/24 4:24:24 来源:https://blog.csdn.net/weixin_43408020/article/details/147255455  浏览:    关键词:找素材的网站大全_成都程序员培训机构_免费访问国外网站的app_市场营销专业就业方向
找素材的网站大全_成都程序员培训机构_免费访问国外网站的app_市场营销专业就业方向

Foreword

Today, we continue to learn Scala Programming, the Scala is hard for Beginner, it has functional coding style.

Text

command style is like Java,C++,Python, function style is like Erlang, Scheme, Haskell. About Scala Coding style, it has two styles: function coding style and command coding style. I recommand to use function coding style, the reason is function coding could reduce the program when it produce bugs. And the style that we could reduce code quantities. Through the below Codes, we together look two different styles.

object day4 {def main(args:Array[String]): Unit = {System.out.println("Scala is make me happy!!");val STRING_array = Array("Scala","Java","C++","Julia","Python","R","C") ;System.out.println("The printArgs:");printArgs(STRING_array);System.out.println("The printArgs2:");printArgs2(STRING_array);System.out.println("The printArgs3:");printArgs3(STRING_array)}def printArgs(args:Array[String]): Unit = {var n = 0;while (n < args.length){println(args(n));n += 1;}}def printArgs2(args:Array[String]): Unit = {for (arg <- args){println(arg);}}def printArgs3(args:Array[String]): Unit = {args.foreach(println)}}

Output Result:
请添加图片描述
请添加图片描述
From the above result, we know the program have var type defined,
haven’t use var type and use for loop, haven’t use for loop and var type declared , we could know the codes are mostly reduce, and the program become easily protect and repair. The key place is val type and var type, val type is function coding style, var type is command coding style. Val is immutable type, it could make less mistakes【Bugs】. And it could improve calculation performance when data is biggest.

However, if you need use command coding style to finish tasks conveniently, No problem, I advise you use the Command coding style. The Scala is good in the compatibility, it could achieve your different requestions.

In the end

I gratitude for your watch my articles, if you seek some wrongs, please you point them, I thanks for you. Please you insist to learn technologies, maybe it’s hard, but I believe in you will get a good result. Cheers!! my dear friends, your Pan【One human of low-quality men】

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com