Ruby idiom for default values

Is there a better way to write this in Ruby, without writing "bar" twice?

foo = bar > 0 ? bar : 1


Not a generic use case, but:

foo = [bar, 1].max

Need Your Help

Sending the same but modifed object over ObjectOutputStream

java io objectoutputstream

I have the following code that shows either a bug or a misunderstanding on my part.

Passing mixed data type array from php to javascript array

javascript php mysql json getjson

This is close to the typical asyncronous / getJSON topics. I can't seem to get mine to work... I am loading an array from mySQL database in a php file "loadblocks.php" and have tested its output to...