1.

Write the difference between “=” and “==”.

Answer»
  • = operator: Assigning the value into a variable is accomplished by using the = operator. It is REFERRED to as the assignment operator.
    Example: Suppose variable a holds 5 and variable B holds 2, then: 
a = $b;  #Would assign value of b to a
  • == operator: This is used to compare strings. In the double equals operator, both operands are COMPARED. If they are equal, it returns true, otherwise, it returns false.
    Example: Suppose variable a holds 5 and variable b holds 2, then:
[ $a == $b ];  #Comparing the values of a and b.


Discussion

No Comment Found