比如这样的:
foreach(path, options = Hash.new, &block)
怎样知道支持哪些 option?
#1 楼 @jjym 举得例子是在 CSV 标准库里的,链接:http://ruby-doc.org/stdlib-1.9.3/libdoc/csv/rdoc/CSV.html#method-c-foreach
这样的参数形式应该很多见了吧,在 Rails 中更多,比如连接数据库的时候,
ActiveRecord::Base.establish_connection(
  :adapter  => "mysql",
  :host     => "localhost",
  :username => "myuser",
  :password => "mypass",
  :database => "somedatabase"
)
假设有时候不记得 :encoding 怎么拼写了,该去哪里看,类似 :adapter、:host 这样所有可用的选项?
The options parameter can be anything ::new understands. This method also understands an additional :encoding parameter that you can use to specify the Encoding of the data in the file to be read.
你看的不仔细
