Title says it all. Why does
if (prev = this.Prev()) {
...
}
work but
if (var prev = this.Prev()) {
...
}
does not? this.Prev() is a method for a Point object which returns a reference to a previous Point if it exists, and false if it does not. I don't want to declare the variable to be global, and I don't want something verbose like:
var prev = this.Prev();
if (prev) {
...
}
EDIT: What's the most elegant way to do something like what I am trying?