首页 > 其他 > 详细

[Ruby]Guide to return statement

时间:2014-07-08 17:18:51      阅读:204      评论:0      收藏:0      [点我收藏+]

In Ruby language, the return statement in the Ruby functions are interesting, Let‘s explore them as below:

def concatenate(name_one=nil, name_two="")
  return name_one + name_two
end

name = concatenate "wuhan", "hubei"
puts name
puts concatenate("shang hai")

def string_as_return(name=nil)
  return "hello, #{name}"
end

puts string_as_return()

puts string_as_return('KD')

def array_as_return(first_name, last_name)
  return first_name, last_name
end

name = array_as_return("Kevin","Durant")

puts name.to_s

puts name.class


[Ruby]Guide to return statement,布布扣,bubuko.com

[Ruby]Guide to return statement

原文:http://blog.csdn.net/wonderfan/article/details/37377459

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!