码迷,mamicode.com
首页 > 其他好文 > 详细

[Ruby]Guide to return statement

时间:2014-07-08 17:19:12      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:ruby

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

标签:ruby

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!