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

搞笑网站源代码nba最新消息新闻报道

搞笑网站源代码,nba最新消息新闻报道,印章在线制作网站,网站建设适合女生吗来到这里的是不是都有以下疑问: 1.build.gradle配置文件结构好复杂啊,怎么记? 2.内部是怎么进行分析和执行的? 3.为什么可以在配置文件里面写groovy代码,怎么识别的? 4.怎么才能很方便的记住和快速上手…

来到这里的是不是都有以下疑问:

1.build.gradle配置文件结构好复杂啊,怎么记?

2.内部是怎么进行分析和执行的?

3.为什么可以在配置文件里面写groovy代码,怎么识别的?

4.怎么才能很方便的记住和快速上手gradle呢?

好的,现在我带着你们的疑问,使用groovy代码的方式,慢慢解开build.grade神秘的面纱,探索其中的奥妙!!!

声明:不要急,我们慢慢深入,请耐心看完

首先我们先看一段groovy代码

        def dependencies = {println("我执行了")}dependencies()

执行结果:

这断代码就是一个无参方法声明和调用,是不是非常简单。

现在我们进一步改造

代码:

        def dependencies = {int a, int b ->println("我执行了" + a + b)}dependencies(1, 2)

 执行结果:

我这次只是加了两个整型参数,进行打印。

好的,我们再次深入改造

代码:

        def dependencies = {int a, int b, Closure c ->println( a+b)c.call()}dependencies(1, 2){println("我执行了")}

 执行结果:

 卧槽,什么鬼!!!!,竟然也行,

重要先看这部分代码

 dependencies(1, 2){println("我执行了")}

这部分代码起始可以看成是两部分:

1. 执行函数部分,dependencies(1, 2)

 2.回调函数逻辑实现部分, 

{println("我执行了")
}

当我们执行

dependencies(1, 2){println("我执行了")
}
这段代码时,实际执行流程就是将
{println("我执行了")
}这部分代码生成回调函数,由Closure对象的call函数进行执行回调 

然后真正执行函数dependencies,然后执行Closure.call执行回调逻辑。

以上都看明白了,现在我们真正进入主题

以gradle配置文件为例子,如下

dependencies {implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

此时你有该蒙蔽了

implementation 'com.google.android.material:material:1.4.0'是什么意思啊,你上面没有说啊,

那好,我们现在说,其实方法调用还有另一种方式

方法名称  参数1[,参数2]

就拿前面举得例子

代码:

        def dependencies = {a ->println("结果:" + a)}dependencies 100

执行结果: 

和dependencies(100)效果是一样的,

那好现在明白了,原来implementation、testImplementation、androidTestImplementation 其实就是内置函数哈。

implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

这些其实都是在调用函数哈,

dependencies {implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

那好,现在我就按照这个配置文件整体实现一下代码。

代码:

 def implementation = {arg ->println("引入接口依赖:" + arg)};def testImplementation  = {arg ->println("引入测试接口依赖:" + arg)};def androidTestImplementation = {arg ->println("引入安卓测试接口依赖:" + arg)}def dependencies = {Closure c ->c.call()}dependencies{implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'}

执行结果:

恍然大悟,原来build.gradle配置文件其实就是在执行各种函数。

应当随时学习,学习一切;应该集中全力,以求知道得更多,知道一切

http://www.hkea.cn/news/919995/

相关文章:

  • 国外设计文章的网站淘宝代运营靠谱吗
  • 市桥网站建设sem论坛
  • 猎头公司是做什么的可靠吗排名优化外包公司
  • 扶贫网站建设关键词查询神器
  • 沈阳酒店企业网站制作公司2023年9月疫情又开始了吗
  • 厦门专业网站建设如何快速推广一个新产品
  • 帮人做传销网站违法吗seo网站排名助手
  • 如何做优品快报下的子网站营销型网站建设目标
  • 用织梦做网站调用乱码营业推广是什么意思
  • 做走私网站北京口碑最好的it培训机构
  • 网站建设OA系统开发it培训机构哪家好
  • 网站运维可以做哪些域名查询网站入口
  • 网站开发的基本语言外贸平台自建站
  • 女生自己做网站营销方法有哪些
  • 怎么自己做网站吓别人金融网站推广圳seo公司
  • 彩票网站的客服有做吗海淀seo搜索优化多少钱
  • 河源哪有做网站网页模板设计
  • 手机网站可以做英文版本吗近三天时政热点
  • 怎么做网站游戏网络优化排名培训
  • ic外贸网站建设黑帽seo技巧
  • 实业有限公司网站怎么做百度一下了你就知道官网
  • 企业电子商务网站推广平台有哪些渠道
  • 本地用织梦做网站百度的网站网址
  • 基础展示营销型型网站新闻发稿平台有哪些
  • 做游戏赚钱的网站最新新闻热点事件2022
  • 商务网站建设哪家好推广代理公司
  • 自己做网站是否要买云主机西安百度提升优化
  • 成都注册公司哪个区好分析网站推广和优化的原因
  • 模板建站杭州seo泽成
  • 济南网站建设公司川芎网络怎么注册自己的网址