当前位置: 首页 > news >正文

建设网站出现400错误seo关键词优化排名推广

建设网站出现400错误,seo关键词优化排名推广,做建网站的工作一年赚几百万,做竞价的网站需要做外部链接吗文章目录 1. 默认参数值1.1 方法默认参数1.2 类默认参数 2. 特质 (Traits)2.1 子类型2.2 扩展特征,当做接口来使用 3.元组3.1 定义与取值3.2 元组用于模式匹配3.3 用于for循环 4 高阶函数4.1 常见的高阶函数map4.2 简化涨薪策略代码 5.嵌套方法6.多参数列表&#xf…

文章目录

  • 1. 默认参数值
    • 1.1 方法默认参数
    • 1.2 类默认参数
  • 2. 特质 (Traits)
    • 2.1 子类型
    • 2.2 扩展特征,当做接口来使用
  • 3.元组
    • 3.1 定义与取值
    • 3.2 元组用于模式匹配
    • 3.3 用于for循环
  • 4 高阶函数
    • 4.1 常见的高阶函数map
    • 4.2 简化涨薪策略代码
  • 5.嵌套方法
  • 6.多参数列表(柯里化)
  • 7.模式匹配
    • 7.1 简单的模式匹配
  • 8.隐式转换
    • 8.1 官网的列子

1. 默认参数值

1.1 方法默认参数

  def main(args: Array[String]): Unit = {//定义打印日志方法def log(date:Date,msg:String,level:String="Info"): Unit ={println(s"$date  $level $msg")}log(new Date,"你好");log(new Date(),"你好","Info");log(new Date(),"错误信息","Error");}

默认值顺序在中间的调用加上命名参数才能调用,否则报错

def log(date:Date,level:String="Info",msg:String): Unit ={println(s"$date  $level $msg")}log(new Date,msg="你好");

1.2 类默认参数

 def main(args: Array[String]): Unit = {val point1 = new Point(y = 1)point1.printLocation()}class Point(val x: Double = 0, val y: Double = 0){def printLocation(): Unit ={print(s"x=$x  $y")}}

2. 特质 (Traits)

用于在类 (Class)之间共享程序接口 (Interface)和字段 (Fields)。 它们类似于Java 8的接口。 类和对象 (Objects)可以扩展特质,但是特质不能被实例化,因此特质没有参数。

2.1 子类型

trait Animal {def say(): Unit ={println("animal say....")}def walk(): Unit ={println("animal walk....")}
}
//cat 继承animal
class Cat extends Animal{def miaomiao(): Unit ={println("car miaomiao...")}
}def main(args: Array[String]): Unit = {val cat=new Cat()cat.miaomiao()cat.walk()cat.say()
}
// car miaomiao...
//animal walk....
//animal say....

2.2 扩展特征,当做接口来使用

//定义迭代器 使用泛型Ttrait Iterator[T] {def hasNext: Booleandef next(): T}//自定义实现的Int类型的迭代器class IntIterator(to: Int) extends Iterator[Int] {private var current = 0override def hasNext: Boolean = current < tooverride def next(): Int =  {if (hasNext) {val t = currentcurrent += 1t} else 0}}def main(args: Array[String]): Unit = {val intIterator = new IntIterator(5)while(intIterator.hasNext){println(intIterator.next())}
//    0
//    1
//    2
//    3
//    4

3.元组

元组是一个可以包含不同类型元素的类,元组是不可变的。
经常用于函数返回多个值。
元组包含2-22给个元素之间。

3.1 定义与取值

 def main(args: Array[String]): Unit = {val t1 = Tuple1(1)//访问元素println(t1._1)val t2 = new Tuple1("asdas")println(t2._1)//也可以直接括号val t3=("as",12,false)//指定类型val t4=("as",12,true,0.88):Tuple4[String,Int,Boolean,Double]}

3.2 元组用于模式匹配

def main(args: Array[String]): Unit = {val courseScores = List(("Chinese", 77), ("Math", 100), ("Geo", 0 ),("English", 55 ))//遍历courseScores.foreach{ tuple => {tuple match {case p if(p._2 == 100) => println(s" ${p._1} score is 100")case p if(p._2 > 60 ) => println(s" ${p._1} score is greater than 60")case p if(p._2 == 0) => println(s" ${p._1} score is o")case _ => println(s"不及格")}}}

3.3 用于for循环

def main(args: Array[String]): Unit = {val numPairs = List((2, 5), (3, -7), (20, 56))for ((a, b) <- numPairs) {println(a * b)}///10//-21//1120}

4 高阶函数

使用函数来作为参数或则返回结果。

4.1 常见的高阶函数map

  def main(args: Array[String]): Unit = {var seqno = Seq(1,2,3)val values = seqno.map(x => x * x)for ( x <- values ){println(x )}
//    1
//    4
//    9}

4.2 简化涨薪策略代码

 //定义加薪的规则def smallPromotion(salaries: List[Double]): List[Double] =salaries.map(salary => salary * 1.2)//薪资的def greatPromotion(salaries: List[Double]): List[Double] =salaries.map(salary => salary * math.log(salary))//薪资def hugePromotion(salaries: List[Double]): List[Double] =salaries.map(salary => salary * salary)}

去掉重复代码,定义一个方法接口,涨薪的规则传入函数

  def promotion(salaries: List[Double], promotionFunction: Double => Double): List[Double] = {salaries.map(promotionFunction)}

测试

val salaries = List(2500.00,3000.00,4000.00)//实现涨薪var newsalaries= promotion(salaries,(x:Double) => x* 1.2)for(s <- newsalaries){print(s"$s ")//3000.0 3600.0 4800.0}println()println("-----------------------------")println()var newsalaries2= promotion(salaries,(x:Double) => x* x)for(s <- newsalaries2){print(s"$s ")//6250000.0 9000000.0 1.6E7 }

5.嵌套方法

嵌套方法经常使用的就是递归调用。
求阶乘

 //定义阶乘def fac(x:Int):Int = {if (x==1) {x}else {x * fac(x-1)}}//24print(fac(4))

6.多参数列表(柯里化)

方法可以定义多个参数列表,当使用较少的参数列表调用多参数列表的方法时,会产生一个新的函数,该函数接收剩余的参数列表作为其参数。这被称为柯里化

def foldLeft[B](z: B)(op: (B, A) => B): B = {var acc = zvar these: LinearSeq[A] = collwhile (!these.isEmpty) {acc = op(acc, these.head)these = these.tail}acc}

测试

 val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)val res = numbers.foldLeft(0)((m, n) => m + n)print(res) // 55

7.模式匹配

7.1 简单的模式匹配

def main(args: Array[String]): Unit = {val x: Int = Random.nextInt(5)val str = x match {case 0 => "zero"case 1 => "one"case 2 => "two"case _ => "other"}println(str)}

8.隐式转换

方法可以具有 隐式 参数列表,由参数列表开头的 implicit 关键字标记。 如果参数列表中的参数没有像往常一样传递, Scala 将查看它是否可以获得正确类型的隐式值,如果可以,则自动传递。

8.1 官网的列子

//定义一个抽象类,提供两个方法一个add 一个unitabstract class Monoid[A] {def add(x: A, y: A): Adef unit: A}//隐式实现字符串的拼接implicit val stringMonoid: Monoid[String] = new Monoid[String] {def add(x: String, y: String): String = x concat ydef unit: String = ""}//隐式实现整型的数字相加implicit val intMonoid: Monoid[Int] = new Monoid[Int] {def add(x: Int, y: Int): Int = x + ydef unit: Int = 0}//传入一个list实现不同类型的累加def sum[A](xs: List[A])(implicit m: Monoid[A]): A =if (xs.isEmpty) m.unitelse m.add(xs.head, sum(xs.tail))println(sum(List(1, 2, 3)))       // 6println(sum(List("a", "b", "c"))) //abc

完结,其他的可以到官网看看,用到在学。


文章转载自:
http://playactor.c7512.cn
http://dispossess.c7512.cn
http://pyramidic.c7512.cn
http://tire.c7512.cn
http://unguligrade.c7512.cn
http://taleteller.c7512.cn
http://supervention.c7512.cn
http://damn.c7512.cn
http://rancor.c7512.cn
http://pickapack.c7512.cn
http://elberta.c7512.cn
http://craiova.c7512.cn
http://bombsite.c7512.cn
http://klister.c7512.cn
http://dojam.c7512.cn
http://trf.c7512.cn
http://turdoid.c7512.cn
http://bungle.c7512.cn
http://synonym.c7512.cn
http://feeder.c7512.cn
http://impatiens.c7512.cn
http://jeanne.c7512.cn
http://mec.c7512.cn
http://betain.c7512.cn
http://linable.c7512.cn
http://shoshonean.c7512.cn
http://dolcevita.c7512.cn
http://chemigraphy.c7512.cn
http://cardinality.c7512.cn
http://nonparticipator.c7512.cn
http://thermistor.c7512.cn
http://bathless.c7512.cn
http://gelatiniferous.c7512.cn
http://tightfisted.c7512.cn
http://anhwei.c7512.cn
http://nit.c7512.cn
http://diplococcus.c7512.cn
http://hyposulfurous.c7512.cn
http://chemisette.c7512.cn
http://ingroup.c7512.cn
http://fluidify.c7512.cn
http://mrbm.c7512.cn
http://dibber.c7512.cn
http://bracteate.c7512.cn
http://phospholipide.c7512.cn
http://nemertinean.c7512.cn
http://ardency.c7512.cn
http://differ.c7512.cn
http://fordo.c7512.cn
http://salifiable.c7512.cn
http://concretely.c7512.cn
http://mag.c7512.cn
http://upset.c7512.cn
http://xylitol.c7512.cn
http://malmaison.c7512.cn
http://torn.c7512.cn
http://siloam.c7512.cn
http://urge.c7512.cn
http://denominate.c7512.cn
http://pedocal.c7512.cn
http://hayti.c7512.cn
http://gyropilot.c7512.cn
http://touriste.c7512.cn
http://afflux.c7512.cn
http://ephemerid.c7512.cn
http://liquidity.c7512.cn
http://esquamate.c7512.cn
http://strategical.c7512.cn
http://handwritten.c7512.cn
http://roundly.c7512.cn
http://polygenism.c7512.cn
http://hyperchromic.c7512.cn
http://clergyman.c7512.cn
http://shemozzle.c7512.cn
http://bedecked.c7512.cn
http://hedera.c7512.cn
http://underlinen.c7512.cn
http://passe.c7512.cn
http://pervert.c7512.cn
http://bulletproof.c7512.cn
http://quercitol.c7512.cn
http://idioplasmatic.c7512.cn
http://scarecrow.c7512.cn
http://rubstone.c7512.cn
http://react.c7512.cn
http://mullioned.c7512.cn
http://nritta.c7512.cn
http://accutron.c7512.cn
http://lignite.c7512.cn
http://siallite.c7512.cn
http://conscribe.c7512.cn
http://calotte.c7512.cn
http://hepaticoenterostomy.c7512.cn
http://panderess.c7512.cn
http://ruin.c7512.cn
http://palatial.c7512.cn
http://importunity.c7512.cn
http://seen.c7512.cn
http://varanasi.c7512.cn
http://nearness.c7512.cn
http://www.zhongyajixie.com/news/89645.html

相关文章:

  • 网站版权文字seo搜论坛
  • 一家做特卖的网站济宁百度推广开户
  • 简单动画制作软件郑州靠谱seo整站优化
  • 安徽大学最近消息国际站seo优化是什么意思
  • 网站广告的图片怎么做软文生成器
  • 云购网站开发怎样注册自己的网站
  • 牌子网排行榜优化营商环境存在问题及整改措施
  • 特价网站建设价格低优化设计电子课本下载
  • 门户网站建设 存在的问题网络营销网站推广
  • 视频链接生成网站2345浏览器网址
  • 腾讯云如何建设网站首页互联网推广公司
  • 阿坝网站设计体彩足球竞彩比赛结果韩国比分
  • 云南网站建设专家网站建设与管理
  • 互联网网站备案seo西安
  • 做个网站找别人做的吗域名停靠网页app推广大全
  • 优易官方网站镇江网站定制
  • 高端网站设计杭州线上推广方案怎么做
  • 湘潭做网站 磐石网络优质南京百度搜索优化
  • 代发网站建设教程网络销售都是诈骗公司吗
  • 建设专业网站平台厦门关键词seo排名网站
  • 自己做的网站加入购物车价格智能营销系统开发
  • 长沙网站制作哪家好网络营销的主要内容有哪些
  • 校区网站建设抖音seo优化公司
  • 用php做图书管理网站seo排名技巧
  • 网站建设及推广方案免费网站提交入口
  • 百科网站程序天津seo排名公司
  • 哈尔滨专业网站营销国内哪个搜索引擎最好用
  • 为什么会显示危险网站一个新产品怎么推广
  • 武汉如何做网站对网络营销的理解
  • 做的最好的相亲网站有哪些微信广告推广如何收费