是的,花括号.
progn evaluates forms, in the order in which they are given.
The values of each form but the last are discarded.
Examples:
(progn) => NIL
(progn 1 2 3) => 3
(progn (values 1 2 3)) => 1, 2, 3
(setq a 1) => 1
(if a
(progn (setq a nil) 'here)
(progn (setq a t) 'there)) => HERE
a => NIL
Run Code Online (Sandbox Code Playgroud)
现在一样,但在scala中:
scala> {}
// Unit is not written explicitly, but it is here
scala> {1; 2; 3}
// warnings omitted
// res1: Int = 3
scala> {(1, 2, 3)}
// res2: (Int, Int, Int) = (1,2,3)
// no direct analog for setq, skipping other examples
Run Code Online (Sandbox Code Playgroud)
并确保您按照给定的顺序评估表单:
scala> {println('1'); println('2'); println('3')}
1
2
3
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
184 次 |
| 最近记录: |