TCL过程中返回和返回1之间的差异

时间:2017-07-26 10:43:36

标签: tcl

在tcl的proc结尾处 return和return 1 之间有什么区别吗?在tcl的proc结尾处 return和return 1 之间有什么区别吗?

2 个答案:

答案 0 :(得分:2)

如果你不告诉它返回任何其他内容,Tcl return命令将只返回空字符串。这三者完全等同:

return
return ""
return {}

显然,return 1是另一回事。

答案 1 :(得分:1)

"返回"没有。 这没什么显示:

#!/usr/bin/tclsh

 proc helloWorld {} {
   return 
 }
 puts [helloWorld]

"返回1"返回值1。 这个显示1:

#!/usr/bin/tclsh

proc helloWorld {} {
  return 1
}
puts [helloWorld]