Chinaunix首页 | 论坛 | 博客
  • 博客访问: 45220
  • 博文数量: 43
  • 博客积分: 1161
  • 博客等级: 少尉
  • 技术积分: 425
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-24 11:14
文章分类
文章存档

2011年(40)

2010年(3)

分类: Python/Ruby

2011-04-25 23:53:57

子程序不仅可以返回标量值,如果在列表上下文中调用,还能返回列表值.
并且,Perl还提供了判断子程序是在标量上下文还是在列表上下文中调用的功能,根据不同的上下文环境返回不同的值.
这个功能靠wantarray函数实现.
  • Returns true if the context of the currently excuting subroutine or eval is looking for a list value
  • Returns false if the context is looking for a scalar
  • Returns the undefined value if the context is looking for no value(void context)
阅读(438) | 评论(0) | 转发(0) |
0

上一篇:Bash Keywords

下一篇:子程序参数

给主人留下些什么吧!~~