標籤:書中源碼是這樣的File.foreach(‘1.txt‘) do |x| if(($. == 1) || x =~ /eig/) .. (($. == 3) || x =~ /nin/) then print x endend其中 1.txt內容如下firstsecondthirdfourthfifthsixthseventheigthninthtenth按道理 讀取第一行的first,$.應該是1
From http://biodegradablegeek.com/2008/04/how-to-post-form-data-using-ruby/POSTing data on web forms is essential for writing tools and services that interact with resources already available on the web. You can grab information from your Gmail
系統內容:Windows 7 sp1Ruby 版本:1.9.2-p0Devkit 版本:4.5吧? 在這個環境下安裝 eventmachine 總是報錯,鬱悶。 Building native extensions. This could take a while...ERROR: Error installing eventmachine: ERROR: Failed to build gem native
Ruby Require VS Load VS Include VS Extend總的來說:require vs load:require只載入一次庫,load可能多次載入,一般情況下用requireinclude vs extend:include的模組中的方法作為類的instance methods,extend的作為class methodsHere are the differences between Require, Load, Include and Extend methods:
正如你所知道的,ruby字串被稱為一流的對象,它使用了大量的查詢和操作方法。一個最基本的字串操作是把一個字串分割成多個子字串。如果你有一個字串,如“foo, bar, baz”而你希望的是這樣三個字串“foo”,“bar”,“baz”。那麼字串類的split方法就可以協助你。 “split”的基本用法
你有多少種方式建立一個方法?大多數人想到的可能是def 關鍵字 Ruby代碼 #普通方法 def tele_you puts "I am Anleb" end #普通方法def tele_you puts "I am Anleb"endRuby代碼 #定義單件方法 n="Anleb" def n.tell_you puts "I am #{self}" end n.tell_you #定義單件方法n="Anleb"def