Created
October 26, 2012 09:02
-
-
Save Liutos/3957747 to your computer and use it in GitHub Desktop.
多重返回值的演示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(truncate 10 3) ;一般情况下返回值为3,即10除以3的商,余数被丢弃了。 | |
(multiple-value-bind (q r) | |
(truncate 10 3) | |
(format t "~D and ~D" q r)) ;输出结果为"3 and 1"。truncate实际上是会返回 | |
;多个值(即多重返回值)的一个函数,不过一般只会得 | |
;到一个,所以要用宏multiple-value-bind来捕捉 | |
;所有的返回值。相当于把(truncate 10 3)的第一个 | |
;返回值赋值给了q,第二个赋值给了r。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go 语言里面的语法没有那么灵活,大概是像这样的: