IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

gradle:grovvy(编辑器、基础语法、闭包)

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

1、grovvy编辑器

(1)在IDEA中打开grovvy编辑器:

84_1.png

(2)grovvy编辑器

84_2.png

(3)运行

84_3.png

执行结果:

84_4.png

2、grovvy基础语法

y(1)语句后的分号可省略:

println("hello world!")

执行结果:

> println("hello world!")
hello world!

(2)可以省略括号:但是println后面需要加空格

println "hello world!"

执行结果:

> println "hello world!"
hello world!

(3)定义变量

数字

def a=8
println a

执行结果:

> def a=8
> println a
8

字符串

def是弱类型的,会根据情况自动赋予类型

def str="hello"
println str

执行结果:

> def str="hello"
> println str
hello

集合类型:

def list=['a','b']
list << 'c'

执行结果:

> def list=['a','b']
> list << 'c'

Result: [a, b, c]

要注意在 << 前后添加空格

集合类型获取元素:

def list=['a','b']
println list.get(1)

取出第二个元素:

> def list=['a','b']
> println list.get(1)
b

map

取值:

def map=['1':'zhai','2':'zhang']
println map.get('1')

执行结果:

> def map=['1':'zhai','2':'zhang']
> println map.get('1')
zhai

添加:

def map = ['1':'zhai','2':'zhang']
map.liu='liu'

执行结果:

> def map = ['1':'zhai','2':'zhang']
> map.liu='liu'

Result: liu

3、grovvy中的闭包

在grovvy中,主要把闭包当参数来使用

(1)闭包的使用

定义一个闭包:

def b1={
    println "hello world"
}

定义一个方法,里面使用闭包类型的参数:

def test(Closure closure){
    closure()
}

调用方法,该方法的参数是闭包类型的:

test(b1)

运行结果:

> def b1={
>     println "hello world"
> }
> def test(Closure closure){
>     closure()
> }
> 
> test(b1)
hello world

(2)带参数的闭包

定义一个带参数的闭包:

def test = {
    v ->
        println "hello ${v}"
}

定义一个方法,参数为闭包类型:

def method(Closure closure){
    closure("world")
}

调用方法:

method(test)

执行结果:

> def test = {
>     v ->
>         println "hello ${v}"
> }
> def method(Closure closure){
>     closure("world")
> }
> method(test)
hello world

文章永久链接:https://tech.souyunku.com/?p=23051


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(60) 打赏



未经允许不得转载:搜云库技术团队 » gradle:grovvy(编辑器、基础语法、闭包)

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367