In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the basic grammars of Scala". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Hello, HelloScala.
Object FunctionApp {def main (args: Array [String]): Unit = {println ("HelloScala.")}}
two。 Basic definition of function / method
Object FunctionApp {def main (args: Array [String]): Unit = {/ / call function println (add (10helm 5)) sayhello () sayhello / / can also be called without parentheses In special cases, you must enter the parameter def add (x:Int) with parentheses / /. Y:Int): Int = {x * y} def sayhello (): Unit = {println ("I don't have a return value.")} / / the special case must be called with parentheses def xm (name:String= "Zhang San"): Unit = { Println (name)} xm () xm ("Li Si")}
3. Conditional expression
Method 1: val x = 100 val a = if (x > 0) {true} else {false} println (a) method 2: val x = 100 val a = if (x > 0) true else false println (a)
4. Cycle mode
/ / left closed and right closed 1 to 10 = 1.to (10) scala.conllection.immutable.Rang.Inclusive = Rang (1 until 2, 3 4 scala.conllection.immutable.Rang.Inclusive = Rang 6 7, 8, 9) / / left close and right open (source code call is also a Rang method) 1 until 10 = 1.until (10) scala.conllection.immutable.Rang.Inclusive = Rang (1 until 10) / left closed and right opened Range (1) scala.conllection.immutable.Rang.Inclusive = Rang / left close and right open (1) The last bit indicates the step size or interval and can not be 0Range (1meme 10jin3) scala.conllection.immutable.Rang.Inclusive = Rang (1meme 4m 7) / / IDEA usage for (I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.