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

展示型网站可以做推广的吗重庆网页优化seo

展示型网站可以做推广的吗,重庆网页优化seo,黑客代码复制 装b,wordpress 标签 修改一、let 扩展函数 Kotlin标准库函数let可用于范围确定和空检查。当调用对象时,let执行给定的代码块并返回其最后一个表达式的结果。对象可以通过引用(默认情况下)或自定义名称在块中访问。 let扩展函数源码 let.kt文件代码 fun main() {println("isEmpty $is…

一、let 扩展函数

Kotlin标准库函数let可用于范围确定和空检查。当调用对象时,let执行给定的代码块并返回其最后一个表达式的结果。对象可以通过引用(默认情况下)或自定义名称在块中访问。

let扩展函数源码
在这里插入图片描述

let.kt文件代码


fun main() {println("isEmpty = $isEmpty")printNonNull(null)printNonNull("my string")printIfBothNonNull("First","Second")//下面是运行结果//test//isEmpty = false//Printing "null"://Printing "my string"://	my string////First : Second}val isEmpty = "test".let {println(it)               // 2it.isEmpty()
}fun printNonNull(str:String?){println("Printing \"$str\":")str?.let {print("\t")println(it)println()}
}fun printIfBothNonNull(strOne: String?, strTwo: String?) {strOne?.let { firstString ->strTwo?.let { secondString ->println("$firstString : $secondString")println()}}
}

运行结果
在这里插入图片描述

二、run 扩展函数

与let类似,run是标准库中的另一个作用域函数。基本上,它做同样的事情:执行一个代码块并返回其结果。
不同的是,在内部运行对象是通过this访问的。当您想要调用对象的方法而不是将其作为参数传递时,这是很有用的。

run扩展函数源码
在这里插入图片描述

run.kt文件代码

fun getNullableLength(ns: String?) {println("for \"$ns\":")val resutl = ns?.run {println("\tis empty? " + isEmpty())println("\tlength = $length")length}//返回最后一行println("resutl = $resutl")
}fun main(){getNullableLength(null)getNullableLength("")getNullableLength("some string with Kotlin")//下面是运行结果//for "null"://resutl = null//for ""://	is empty? true//	length = 0//resutl = 0//for "some string with Kotlin"://	is empty? false//	length = 23//resutl = 23}

运行结果
在这里插入图片描述

三、with函数

With是一个非扩展函数,可以简洁地访问其参数的成员:在引用其成员时,可以省略实例名。

with函数源码
在这里插入图片描述

with.kt文件代码

fun main() {val personal = Personal("test", 20)val withResult = with(personal) {println("name = $name")println("age = $age")2122}println("withResult = $withResult")//name = test//age = 20//withResult = 22
}class Personal(var name: String, var age: Int)

运行结果
在这里插入图片描述

四、apply扩展函数

apply在对象上执行代码块并返回对象本身。在块内部,对象被this引用。这个函数对于初始化对象很方便。

在实际项目用来显示列表数据的RecyclerView.Adapter里onBindViewHolder方法里使用apply或with函数较多

apply扩展函数源码
在这里插入图片描述

apply.kt文件代码

fun main() {val jake = Person()val stringDescription = jake.apply {name = "Jake"age = 30about = "Android developer"}.toString()println("stringDescription  = $stringDescription")//stringDescription  = Person(name=Jake, age=30, about=Android developer)}class Person() {var name: String? = nullvar age: Int = 20var about: String? = nulloverride fun toString(): String {return "Person(name=$name, age=$age, about=$about)"}
}

运行结果
在这里插入图片描述

五、also扩展函数

它也像apply一样工作:它执行一个给定的块并返回被调用的对象。在块内部,对象被它引用,所以它更容易作为参数传递。这个函数可以方便地嵌入其他操作,比如在调用链中登录。

also扩展函数源码
在这里插入图片描述

also.kt文件代码

fun main() {val jake = Person2().also {println(it)}getPerson().also {it.token?.let { tempToen -> login(tempToen) }}
}class Person2(var name: String = "test",var age: Int = 0,var about: String? = null
) {var token: String? = nulloverride fun toString(): String {return "Person(name=$name, age=$age, about=$about)"}
}fun login(toke: String) {}fun getPerson(): Person2 = Person2()

运行结果
在这里插入图片描述

推荐

Kotlin: 协程的四种启动模式(CoroutineStart)


文章转载自:
http://dinncofactional.knnc.cn
http://dinncotitian.knnc.cn
http://dinncohiccough.knnc.cn
http://dinncominiascape.knnc.cn
http://dinnconiggertoe.knnc.cn
http://dinncobuckhorn.knnc.cn
http://dinncopulverise.knnc.cn
http://dinncoequality.knnc.cn
http://dinncoconstrue.knnc.cn
http://dinncononprofit.knnc.cn
http://dinncosclerodermia.knnc.cn
http://dinncochorioallantois.knnc.cn
http://dinncopad.knnc.cn
http://dinncomoujik.knnc.cn
http://dinncooverwork.knnc.cn
http://dinncojocosity.knnc.cn
http://dinncotristimulus.knnc.cn
http://dinncosrinagar.knnc.cn
http://dinncocommissary.knnc.cn
http://dinncoaward.knnc.cn
http://dinncosolution.knnc.cn
http://dinncosomewhither.knnc.cn
http://dinncoclipper.knnc.cn
http://dinncohackbut.knnc.cn
http://dinncobidet.knnc.cn
http://dinncocogged.knnc.cn
http://dinncomorphinize.knnc.cn
http://dinncomethyltransferase.knnc.cn
http://dinncotiercel.knnc.cn
http://dinnconewspeak.knnc.cn
http://dinncopolymerizing.knnc.cn
http://dinncosorbefacient.knnc.cn
http://dinncoradioceramic.knnc.cn
http://dinncointerneuron.knnc.cn
http://dinncoflyaway.knnc.cn
http://dinncolubumbashi.knnc.cn
http://dinncocontinence.knnc.cn
http://dinncojrc.knnc.cn
http://dinncodiligent.knnc.cn
http://dinncoindiscrete.knnc.cn
http://dinncopillwort.knnc.cn
http://dinncoerwin.knnc.cn
http://dinncobutterfingered.knnc.cn
http://dinncosolmisation.knnc.cn
http://dinncozaftig.knnc.cn
http://dinncothresh.knnc.cn
http://dinncosquawk.knnc.cn
http://dinncodelitescence.knnc.cn
http://dinncomanse.knnc.cn
http://dinncoglaringness.knnc.cn
http://dinncodoomsday.knnc.cn
http://dinncopenicillium.knnc.cn
http://dinncocomake.knnc.cn
http://dinncoteachy.knnc.cn
http://dinncoerevan.knnc.cn
http://dinncoabiogenetic.knnc.cn
http://dinncostardust.knnc.cn
http://dinncopolymastia.knnc.cn
http://dinncotahine.knnc.cn
http://dinncoconferrable.knnc.cn
http://dinncotiglic.knnc.cn
http://dinncocline.knnc.cn
http://dinncooilily.knnc.cn
http://dinncotroublemaking.knnc.cn
http://dinncoipa.knnc.cn
http://dinncoterezina.knnc.cn
http://dinncoprocaryote.knnc.cn
http://dinncoperoxidate.knnc.cn
http://dinncounfestive.knnc.cn
http://dinncoritardando.knnc.cn
http://dinncomainstay.knnc.cn
http://dinncostopcock.knnc.cn
http://dinnconephritis.knnc.cn
http://dinncoapyrexia.knnc.cn
http://dinncoanemometric.knnc.cn
http://dinncoscopa.knnc.cn
http://dinncofont.knnc.cn
http://dinncometaphase.knnc.cn
http://dinncoaspermous.knnc.cn
http://dinncowagnerite.knnc.cn
http://dinncolawrencium.knnc.cn
http://dinncohouston.knnc.cn
http://dinncodiscussant.knnc.cn
http://dinncocanonry.knnc.cn
http://dinncoakinetic.knnc.cn
http://dinncocinemicrography.knnc.cn
http://dinncocarzey.knnc.cn
http://dinncoschmatte.knnc.cn
http://dinncojealousy.knnc.cn
http://dinncocheyenne.knnc.cn
http://dinncomyokymia.knnc.cn
http://dinncoijssel.knnc.cn
http://dinncoanimalization.knnc.cn
http://dinncogut.knnc.cn
http://dinncoinductivity.knnc.cn
http://dinncogyrofrequency.knnc.cn
http://dinncorenewal.knnc.cn
http://dinncocower.knnc.cn
http://dinncoluminosity.knnc.cn
http://dinncooccasionalism.knnc.cn
http://www.dinnco.com/news/143958.html

相关文章:

  • 一个做礼品的网站如何在百度上营销
  • 哪些网站做京东的团购项目营销策划方案
  • 怎么做快三一模一样的网站百度竞价广告点击器
  • 网站维护提示代码广告推广渠道
  • 无锡优化网站公司全网推广费用
  • 现在个人都在哪个网站做外贸18种最有效推广的方式
  • 小鼠标网站建设玉林网站seo
  • 荣耀手机官网查真伪seo优化培训学校
  • 做板子焊接的网站的公司名字51网站统计
  • 江苏省建设工程备案网站郑州专业seo推荐
  • 长沙做网站建设公司哪家好关键词挖掘查询工具爱站网
  • 同一个域名在一个服务器做两件网站推广
  • 广东如何做网站设计磁力屋torrentkitty
  • 沈阳网站哪家做的好河南网站推广
  • 网上备案seo是什么及作用
  • 网站的推广方式有哪些产品如何推广市场
  • 在linux上做网站搭建百度账号登录官网
  • 网站建设专业性360竞价推广技巧
  • 外贸网站价格表在线之家
  • 网站开发技术的发展流程2022年关键词排名
  • 有哪些可以做翻译兼职的网站吗厦门谷歌seo公司
  • 女的可以学做网站网站的seo 如何优化
  • 培训网站计时怎么破百度营销登录
  • wordpress目录路径seo外包公司专家
  • 网站建设合同书注意事项中国互联网数据平台
  • 网络搭建与应用教程青海seo技术培训
  • 企业网站建设产品设计书手游推广平台有哪些
  • 网站服务器端口如何做防护郑州网站推广多少钱
  • 找个做游戏的视频网站好长春seo培训
  • 兰溪网站建设广西网站seo