When is 4 – 1 = 4?

When c like languages say so

$a = 5;
$b = 1;
 
$result = $a---$b;
echo $a; #=>4
echo $b; #=>1
echo $result; #=>4
public class FunMaths{
	public static void main(String[] args) {
		int result;
		int a = 5, b = 1;
		result = a---b;
		System.out.println(a);
		System.out.println(b);
		System.out.println(result);
	}
}


Related posts:

  1. Orms and Circular References
  2. Trollin Oracle
  3. PHP Functions, you’re doing it wrong…
  4. Making isset Recursive
  5. Documenting PHP Code

Tags: , , , , , ,

  • http://tiso.wz.cz/ tiso
  • http://blog.seanja.com/ SeanJA

    The trick here is that it is doing either a prefix or postfix decrement (I guess it would depend on the compiler).

    In the case of php and java, it does a postfix decrement, then it ignores the -1 on the end, resulting in {4, 1, 4}

  • L

    I don’t think I’m getting the joke…have you overloaded the – operator?
    triple – operators doesn’t have a valid meaning I’m aware of in C, at least. One is minus, two is decrement.