Forked from JoshCheek/local_var_overwrite_warning.rb
Created
December 27, 2011 22:47
-
-
Save ezkl/1525397 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Much more realistic context. | |
def extract_prefix_from_path(path) | |
/(?<prefix>.+)_path/ =~ path.to_s ? prefix : false | |
end | |
path = extract_prefix_from_path("homepath") | |
puts path #=> false | |
puts extract_prefix_from_path("home_path") #=> home |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment