What does the term "Array operator" mean?

A type of operator which allows you to perform actions on two or more arrays and their contents.

Although they vary in how they are written between languages, the array operators are roughly as follows:

OperatorExampleDescription
+apples=[“russet”=>2,”cox”=>5,”golden delicious”=>2]
pears=[“dessert”=>3, “conference”=>2]

 

apples + pears returns [“russet” => 2, “cox” => 5, “dessert” => 3, “conference” => 2]

Makes a new array containing all items from the arrays (also known as a union)
==agesString = [“Andy” => “32”, “Barry” => “42”];
agesNumber = [“Andy” => 32, “Barry” => 42];

 

agesString == agesNumber returns true

Returns true or false. For true, the arrays must have the same key/value pairs
===agesString = [“Andy” => “32”, “Barry” => “42”];
agesNumber = [“Andy” => 32, “Barry” => 42];

 

agesString === agesNumber returns false

Returns true or false. For true, the arrays must have the same key/value pairs and these must be the same data type
!= or <>agesString = [“Andy” => “32”, “Barry” => “42”];
agesNumber = [“Andy” => 32, “Barry” => 42];

 

agesString == agesNumber returns false

Returns true or false. For false, the arrays must have the same key/value pairs
!==agesString = [“Andy” => “32”, “Barry” => “42”];
agesNumber = [“Andy” => 32, “Barry” => 42];

 

agesString === agesNumber returns true

Returns true or false. For false, the arrays must have the same key/value pairs and these must be the same data type

Leave a Reply

Thank you for choosing to leave a comment. Comments may be moderated.