程式碼高𠅙

2009/05/05

有趣的 Ruby 字串操作

irb(main):025:0> a= "abc def"
=> "abc def"
irb(main):026:0> a["def"] = "abc"
=> "abc"
irb(main):027:0> a
=> "abc abc"
irb(main):028:0> a["abc"] = "xyz"
=> "xyz"
irb(main):029:0> a
=> "xyz abc"
irb(main):030:0> a["abc"]
=> "abc"
irb(main):031:0> a["def"]
=> nil
irb(main):032:0>

date = "2009/12/12"
month, day, year = date.split('/')

Technorati : ,

沒有留言: