Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active August 18, 2018 01:57
Show Gist options
  • Save YumaInaura/8204c34a17e1547274ff8907ca3759cf to your computer and use it in GitHub Desktop.
Save YumaInaura/8204c34a17e1547274ff8907ca3759cf to your computer and use it in GitHub Desktop.
Ruby—Return true when an array includes a value other array has

Ruby—Return true when an array includes a value other array has

# Both arrays has :C value
([:A, :B, :C] & [:C, :D, :E]).size > 0
# => true

# Both array has no same value
([:A, :B, :C] & [:D, :E, :F]).size > 0
# => false

Versions

  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment