免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2657 | 回复: 3
打印 上一主题 下一主题

恳请大神来解释一下! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-12-05 16:05 |只看该作者 |倒序浏览
这是程序
当子程序中的print禁止的时候,结果如图
当子程序中的Print输出的时候,结果如图
请问$result结果为什么会有不同?

论坛徽章:
6
卯兔
日期:2013-11-26 14:52:02丑牛
日期:2014-02-19 18:01:25卯兔
日期:2014-05-20 20:34:06白羊座
日期:2014-05-23 13:39:232015亚冠之大阪钢巴
日期:2015-08-07 20:57:582015亚冠之大阪钢巴
日期:2015-09-02 14:09:09
2 [报告]
发表于 2014-12-05 18:17 |只看该作者
lz你要明白函数的返回值是什么,如果函数里面没有return,是返回最后一行作为返回值
注释掉print时,return $i=120,
没注释print时,reurn (print xxxx),是scalar,值为1

The return value of the subroutine (or of any other block, for that matter) is the
value of the last expression evaluated. Or, you may use an explicit return state-
ment to specify the return value and exit the subroutine from any point in the
subroutine. Either way, as the subroutine is called in a scalar or list context, so
also is the final expression of the routine evaluated in that same scalar or list
context


回复 1# yxmingliang


   

论坛徽章:
7
巳蛇
日期:2013-11-28 09:22:59天秤座
日期:2014-10-25 15:40:452015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:172015亚冠之德黑兰石油
日期:2015-07-15 08:46:452015亚冠之平阳省
日期:2015-11-08 16:27:53白银圣斗士
日期:2015-11-14 09:58:12
3 [报告]
发表于 2014-12-05 20:27 |只看该作者
回复 2# 只是一个红薯


    此楼正解!!!

论坛徽章:
0
4 [报告]
发表于 2014-12-05 21:18 |只看该作者
请问返回值为什么是1呢?是表示true么?回复 2# 只是一个红薯


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP