Skip to content

Instantly share code, notes, and snippets.

@colorbox
Last active Jan 21, 2019
Embed
What would you like to do?
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