From: "Marcin Mielżyński" Date: 2006-09-24T02:20:13+09:00 Subject: Re: Riddle me this (a question about expressions) Patrick Toomey wrote: > Hello all, > I am new to Ruby and am toying around with the language to get a feel > for the expression ubiquity in ruby. Anyway, explain to me the > following. The below bits of code have no real relevance; they are > merely illustrative of my question. The first declaration works as > expected; the return value is 9. The second declaration doesn't run at > all. I get a "void value expression" error. Is the runtime looking > into my if statement, realizing that there is no ability for x to get > set and failing? Obviously the code is ridiculous, but it seems odd to > me that it would not even run. Why does the interpreter care that x > will never get set if the function will return cleanly none the less? > > def foo() > x = 0 > x = if 3 > 4 > 8 > else > 9 > end > return x > end > > def foo() > x = 0 > x = if 3 > 4 > return 8 > else > return 9 > end > return x > end > I think the return statement has void context itself check out this - in fact what you are doing is: return (return "foo") lopex