-
-
Save poshboytl/8791aea6b59438ce19098fcf755c513f to your computer and use it in GitHub Desktop.
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
# 这个函数在做什么? 你觉得它为什么要这么做? | |
def compare(a, b) | |
return false if a.blank? || b.blank? || a.bytesize != b.bytesize | |
l = a.unpack "C#{a.bytesize}" | |
res = 0 | |
b.each_byte { |byte| res |= byte ^ l.shift } | |
res == 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment