atnd.org
Rubyでメソッドチェーンの途中経過を覗き見るには Kernel#tapが便利だよね (1..10).tap{ |x| puts x.inspect } .to_a.tap{ |x| puts x.inspect } .select { |x| x % 2 == 0 }.tap{ |x| puts x.inspect } .map { |x| x * x }.tap{ |x| puts x.inspect } # >> 1..10 # >> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # >> [2, 4, 6, 8, 10] # >> [4, 16, 36, 64, 100] tapのブロックにはもちろんいろいろな手続が書けるけど やっぱり出力系メソッドがよく使われると思うんだ それならいっそのこと それらのメソッドがselfを返すようにして しかも引数を取らないとき
Using the select parameter in Active Record association your can speed up you application about 50% and more. The following example is only focused on the optimization of the association using select, so there are further optimizations for the following examples. Given the models: class Patient < ActiveRecord::Base belongs_to :physician end class Physician < ActiveRecord::Base has_many :patients e
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く