Ruby變數名的首位字元來確定它是局部變數、執行個體變數、類變數、全域變數還是常數。通常情況下,變數名的第二位字元以後是數字、字母或底線,但有的內部變數名比較特殊s = 'Hello World!'x = 10# p004stringusage.rb# Defining a constantPI = 3.1416puts PI# Defining a local variablemyString = 'I love my city, Pune'puts
ruby -v #查看ruby 版本 ruby -e ''require"watir"; puts Watir::IE::VERSION'' #查看watir版本rvm list known #列出已知的ruby版本rvm install 1.9.3rvm use 1.9.3 | rvm use systemrvm use 1.9.3 --defaultrvm list #列出本地ruby版本rvm remove 1.9.2具體詳情見RVM實用指南
Ruby學習筆記ruby使用方法the first half of rubywe are defining, we are creating例如 blue_crystal=1 , leaf_tender=5the second half of rubyputting things in motion例如 pipe.catch_a_star總結:1.defining things 2.putting those things into action
Symbol 是什麼 Ruby 是一個強大的物件導向指令碼語言(本文所用 Ruby 版本為1.8.6),在 Ruby 中 Symbol 表示“名字”,比如字串的名字,標識符的名字。建立一個 Symbol 對象的方法是在名字或者字串前面加上冒號:建立 symbol 對象:foo:test :”abc”:"I am a boy” 你可能會問,字串就是字串,幹嗎還有字串的名字?這是因為在 Ruby 中字串也是一種對象,即 String 對象。無論其結構還是操作和 Symbol 對象都是不同的。
Ruby Plus is a site offering free Ruby and Rails related screencasts recorded by Bala Paranj, much in the same vein as Ryan Bates' Railscasts. The screencasts are generally similar in length and overall format to those from Railscasts. So far there