==

=
==
equals

1 Bash[ | ]

i=1
j=2
if [ "$i" = "$j" ]
then
  echo "i == j"
else
  echo "i != j"
fi
# i != j
i=1
j=2
if [ "$i" = "$j" ]; then echo YES; else echo NO; fi
if [ $i = $j ]; then echo YES; else echo NO; fi
if [ $i -eq $j ]; then echo YES; else echo NO; fi
# NO
# NO
# NO
i=2
j=2
if [ "$i" = "$j" ]; then echo YES; else echo NO; fi
if [ $i = $j ]; then echo YES; else echo NO; fi
if [ $i -eq $j ]; then echo YES; else echo NO; fi
# YES
# YES
# YES
i="hello world"
j="hello my friend"
if [ "$i" = "$j" ]; then echo YES; else echo NO; fi
# NO

if [ $i = $j ]; then echo YES; else echo NO; fi
# -bash: [: too many arguments
# NO
if [ $i -eq $j ]; then echo YES; else echo NO; fi
# -bash: [: too many arguments
# NO

2 Cmd[ | ]

set my_name=John Smith&rem
IF "%my_name%"=="John Smith" ECHO my_name is John Smith
set my_name="John Smith"
IF %my_name%=="John Smith" ECHO my_name is "John Smith"

3 C#[ | ]

int i = 1;
int j = 1;
if( i==j ) Console.WriteLine("i == j");
else  Console.WriteLine("i != j");
// i == j

4 JavaScript[ | ]

Array.prototype.equals = function (array) {
  if (!array) return false;
  if (this.length != array.length) return false;
  for (var i=0, l=this.length; i<l; i++) {
    if (this[i] instanceof Array && array[i] instanceof Array) if (!this[i].equals(array[i])) return false;       
    else if (this[i] != array[i]) return false;
  }       
  return true;
}
var a = ['a', 1, 'c'];
var b = ['a', 1, 'c'];
if( a.equals(b) ) alert('a = b');

5 PHP[ | ]

$i = 1;
$j = 2;
if( $i == $j ) echo "i == j";
else echo "i != j";
// i != j

6 Python[ | ]

if 1 == 1:
	print(True)
else:
	print(False)
# True
if 1 == 2:
	print(True)
else:
	print(False)
# False

7 Ruby[ | ]

puts 2 == 2
# true
puts 2 == 3
# false

8 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}