It is said that Ruby is a metaprogramming language. I wonder if the first 3 lines can be made less verbose using metaprogramming?
RUBY_VERSION ||= "unknown version"
RUBY_PATCHLEVEL ||= "unknown patchlevel"
RUBY_PLATFORM ||= "unknown platform"
print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ", RUBY_PLATFORM
This does the job:
but I think it’s opaque and unpleasant. I think your original version is much better. In particular, I think
||=with constants isn’t great anyway (since constants shouldn’t be dynamic), and that usingevalwith constants is not standard or therefore expected. Putting conditional assignment, constants and eval all together makes for a bad mix, in my opinion.