Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the anonymous function of spark

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use the anonymous function of spark". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the anonymous function of spark.

Variable and constant scala > var a = addOne (4) a: Int = 5scala > var a = 123a: Int = 123scala > a = 124a: Int = 124scala > val b = "demo" b: String = demoscala > b = "demo2": 27: error: reassignment to val b = "demo2" ^ function scala > def addOne (m:Int): Int = {| muni1 |} addOne: (m:Int) Intscala > var a = addOne (4) a: Int = 5 anonymous function scala > (x:Int) = > x+1res0: Int = > Int = scala > var addOne = (x:Int) = > x+1addOne: Int = > Int = scala > addOne (3) res1: Int = 4 multiline anonymous function Pass in multiple parameters scala > def mult = {(x var Intjjjn) = > | var z = x * y | zhun 19 |} mult: (Int) Int) = > Intscala > mult (4Power5) res6: Int = 39 object scala > class Person {| var age: Int = 30 | | def grow (): Int = {| age = age + 1 | age | | |} |} | Defined class Person Scala > var person = new Person person: Person = $iwC$$iwC$Person@2183cb14 Scala > person.grow () res2: Int = 31 scala > person.grow () Res3: Int = 32 so far I believe you have a deeper understanding of "how to use the anonymous function of spark". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report