Compare commits

...

3 Commits

Author SHA1 Message Date
ShaliniR8
fd6d910fc9
Merge a51eb67742 into 770a4138b4 2024-12-18 14:58:24 -07:00
Shalini Roy
a51eb67742 Introduce inspect 2024-12-12 05:29:23 -08:00
Shalini Roy
6efba3485e Set operations 2024-12-12 05:28:59 -08:00

View File

@ -55,6 +55,12 @@ a multi-line comment with the # character.
3 | 5 #=> 7 3 | 5 #=> 7
3 ^ 5 #=> 6 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 # Arithmetic is just syntactic sugar
# for calling a method on an object # for calling a method on an object
1.+(3) #=> 4 1.+(3) #=> 4
@ -552,6 +558,9 @@ dwight.name #=> "Dwight K. Schrute"
# Calling of a class method # Calling of a class method
Human.say('Hi') #=> "Hi" Human.say('Hi') #=> "Hi"
# Tip: Use .inspect to see instance with instance variables
puts jim.inspect #=> #<Human:0x000058b3c7f0c7a0 @name="Jim Halpert", @age=0>
# Variable's scopes are defined by the way we name them. # Variable's scopes are defined by the way we name them.
# Variables that start with $ have global scope. # Variables that start with $ have global scope.
$var = "I'm a global var" $var = "I'm a global var"