Last active
January 21, 2019 08:02
-
-
Save colorbox/ef73925461d92f7b91bf2e0aba5535d9 to your computer and use it in GitHub Desktop.
lazy確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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