30 Apr 21:00
Overloading the divide symbol on String to facilitate path concatenation?
Michael Bishop <mbishop <at> me.com>
2012-04-30 19:00:12 GMT
2012-04-30 19:00:12 GMT
Hello fellow rake developers,
I started using this construction in my rake files and I wanted to get your opinion on it (though if there is a
better forum, please direct me there).
Problem
-------
In my rake scripts, I like to assign directory paths to variables so I can use the variables later in my
program. The problem is, when concatenating the variables, I end up with ugly combinations like:
File.join(BUILD_D, "bin", "x86")
File.join(CACHE_D, "scripts", SCRIPT_TEMP_NAME)
Possible Solution
-----------------
I find this hard to read so I tried something:
class String
def /(path)
if !path
self
else
File.join(self, path)
end
end
end
(Continue reading)
Seems to me that #2 and #3 are related to newlines output in the
console, perhaps there is another way to verify the output
independently of LF/CR?
RSS Feed