Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created May 28, 2009 16:58
Show Gist options
  • Select an option

  • Save practicingruby/119440 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/119440 to your computer and use it in GitHub Desktop.
if RUBY_VERSION < "1.9"
def ruby18
yield
end
def ruby19
false
end
else
def ruby18
false
end
def ruby19
yield
end
end
# later
def read_file
ruby18 { File.read("foo.txt") } ||
ruby19 { File.read("foo.txt", :encoding => "UTF-8" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment