zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    jsp4个作用域
    jsp9个内置对象
    jsp指令
    jsp注释
    jsp原理
    java面试
    代理
    泛型
    exception
    基础
  • 原文地址:https://www.cnblogs.com/heidsoft/p/3843219.html
Copyright © 2011-2022 走看看