Example Using Conditional Equations
To
find out which equation is applicable, we have to calculate
whether m0
contains the key k0
:
emptyMap().add("blue",1).add("green",2).containsKey("blue") m0 .add( k0, v0).containsKey( x )
There are two equations that might match that as well, so we
have to calculate whether x.equals(k0)
, that is, whether
"blue".equals("green")
.
Our knowledge of Java tells us that
comes out false, so we simplify using the second equation for
containsKey
:
emptyMap().add("blue",1).add("green",2).containsKey("blue") m0 .add( k0, v0).containsKey( x ) = emptyMap().add("blue",1).containsKey("blue") m0 .add( k0, v0).containsKey("blue")