Big Data learning --scala function and method

package com

/**
  * Created by Administrator on 2019/4/8.
  */
object TestMap {


  def ttt(f: Int => Int): Unit = {
    val r = f(10)
    println(r)
  }

  val f0 = (x: Int) => x * x


  def m0(x: Int): Int = {

    x * 11
  }

  def main(args: Array[String]) {
    //    val arr=Array(1,2,3,4,5,6,7,8,9)
    //    val r=arr.map(x => x * 10)
    //    println(r.toBuffer)
    ttt(f0)
    ttt(m0 _)
    ttt(m0) //The name of a method of spread functions which, in fact, the method of converting a function spread inside method using underscore 
    TTT ((X => M0 (X))) 
    TTT (X => M0 (X)) 
  } 
}

 

Guess you like

Origin www.cnblogs.com/feifeicui/p/10955174.html
Recommended