Skip to content

Instantly share code, notes, and snippets.

@colorbox
Last active January 21, 2019 08:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save colorbox/ef73925461d92f7b91bf2e0aba5535d9 to your computer and use it in GitHub Desktop.
lazy確認
class Hoge
attr_accessor :body
def initialize(body)
@body = body
end
def squisher
pp "i squished #{@body}"
@body.squish
end
def gsuber
pp "i gsub #{@body}"
@body.gsub(/[[:space:]]/, '')
end
end
hoges=[Hoge.new(" 123"),Hoge.new("1 23"),Hoge.new("12 3"),Hoge.new("123 "),Hoge.new("1 2 3")].map{|m|m.squisher}.uniq
hoges.include?('1huga')
lazy_hoges=[Hoge.new(" 123"),Hoge.new("1 23"),Hoge.new("12 3"),Hoge.new("123 "),Hoge.new("1 2 3")].lazy.map{|m|m.squisher}.uniq
lazy_hoges.include?('1huga')
hoges=[Hoge.new(" 123"),Hoge.new("1 23"),Hoge.new("12 3"),Hoge.new("123 "),Hoge.new("1 2 3")].map{|m|m.gsuber}.uniq
hoges.include?('1huga')
lazy_hoges=[Hoge.new(" 123"),Hoge.new("1 23"),Hoge.new("12 3"),Hoge.new("123 "),Hoge.new("1 2 3")].lazy.map{|m|m.gsuber}.uniq
lazy_hoges.include?('1huga')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment