设为首页 加入收藏

TOP

[Ruby]Guide to return statement
2015-07-24 05:40:47 来源: 作者: 【 】 浏览:4
Tags:Ruby Guide return statement

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


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 1573:Robot Motion 下一篇POJ 3093 Margaritas on the Rive..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: