From 6efba3485e7444c8c63c9a8c2f0cbf88c22fda6c Mon Sep 17 00:00:00 2001 From: Shalini Roy Date: Thu, 12 Dec 2024 05:28:59 -0800 Subject: [PATCH] Set operations --- ruby.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruby.md b/ruby.md index c8ba6f42..9cec8e3f 100644 --- a/ruby.md +++ b/ruby.md @@ -55,6 +55,12 @@ a multi-line comment with the # character. 3 | 5 #=> 7 3 ^ 5 #=> 6 +# Overload bitwise operators to perform +# set operations +[1,2] & [2,3,4] #=> [2] +[1,2] | [2,3,4] #=> [1,2,3,4] +[1,2] ^ [2,3,4] #=> [1,3,4] + # Arithmetic is just syntactic sugar # for calling a method on an object 1.+(3) #=> 4