ruby 数组与散列

def say_goodnight(name)
  result ="Good night ." +name
  return result
end

def say_goodmorning(name)
  result ="Good morning .#{name}" 
  return result
end

def say_goodafternoon(name)
  result ="Good afternoon .#{name}" 
end


puts say_goodnight("jake")

puts say_goodmorning("heidsoft")

puts say_goodafternoon("heidcloud")

a =[1,'cat',3.14]
a[0]=nil
puts a

b=%w{jake heidsoft heidcloud}

#散列 =>左边是建,右边是值
cloud_system={
    'java' => 'CloudStack',
    'Python' =>'OpenStack',
    'c/c++' =>'OpenNebula'
}

puts cloud_system['java']
puts cloud_system['Python']

count=1
tries=2
if count>3
  puts 'java'
elsif tries=3
  puts 'python'
else
  puts 'c/c++'
end
weight=0
hight=100
# while weight <100 and hight<=200
#   count+=1
# end
#
puts count
while line=gets
  puts line.downcase
end

#nil=false
if count>100
  puts "count > 100"
end
#这种写法和上面的一样
puts "count > 100" if count>100

square =2
while square <1000
  square=square*square
end

 

转载于:https://www.cnblogs.com/heidsoft/p/3843219.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值