为什么以下语句的输出为真?
VAR="[[ "x"=="y" ]]"
if eval $VAR ; then
echo "true"
else
echo "false"
fi
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以使用变量作为 bash 中 if 语句的条件?
有人能告诉我为什么这会返回真的吗?我想如果我将某些内容转换为例如Object然后调用.equals,则将使用默认实现Object.并且s1 == s2应该返回false: - /
请告诉我在哪个主题下我可以找到更多关于此行为的信息.
Set<String> s1 = new HashSet<String>(as("a"));
Set<String> s2 = new HashSet<String>(as("a"));
Object o1 = (Object)s1;
Object o2 = (Object)s2;
System.out.println(o1.equals(o2));
Run Code Online (Sandbox Code Playgroud)