From: Josh Cheek Date: 2011-01-15T23:55:54+09:00 Subject: Re: what's the difference between these two snippets of ruby? --00163628369c4583b10499e3bf93 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jan 15, 2011 at 8:06 AM, Mr. Bill wrote: > Sorry I couldn't help the line wrapping. Thanks in advance. > > parent_path = > File.expand_path(config['parent'], > File.dirname(yaml_path)).gsub('${project_dir}', > PROJECT_ROOT) > > > config['parent'].gsub!("${project_dir}", PROJECT_ROOT) > parent_path = File.expand_path(config['parent'], > File.dirname(yaml_path)) > > -- > Posted via http://www.ruby-forum.com/. > > The second version modifies config['parent'] If you want the second version, which is much easier to understand, imo. But don't want the side effect of changing the config hash, then use gsub without the bang, and assign it to a local variable: parent = config['parent'].gsub("${project_dir}", PROJECT_ROOT) parent_path = File.expand_path( parent , File.dirname(yaml_path) ) --00163628369c4583b10499e3bf93--