随笔分类 - Ruby
摘要:module BaseFunc Version="0.0.1" def V return Version end def add(a,b) return a+b end def self.showVersion return Version end #将V方法定义为静态方法 module_funct
阅读全文
摘要:class Game def initialize(id,title,price) @id=id @title=title @price=price end def showGame puts @id+" "+@title+","+@price._to_s end def self.toStr pu
阅读全文
摘要:#字符转数值 FG="50" P3="40" FT="90" puts FG+P3+FT puts FG.to_i+P3.to_i+FT.to_i puts (FG.to_i+P3.to_i+FT.to_i).to_s+"俱乐部" puts FG.to_i puts FG.to_i.to_f put
阅读全文
摘要:#键值对 mvp_rank={ "curry"=>28.1, "harden"=>30.3, "lebron"=>26 } puts mvp_rank puts mvp_rank["harden"] player={ name:"harden", age:28, point:30.3 } puts
阅读全文
摘要:1.函数 def sayHello(name="Levi") puts "hello #{name}." end sayHello 结果如下 2.类 class Player def initialize(name="levi")#构造函数 @name=name end def show() put
阅读全文