The old File.rename not working again

Hi --

···

On Tue, 9 Oct 2007, William James wrote:

Furthermore, why say ".length" when you can say ".size"?

For some reasons, I like #length for strings and #size for arrays.
I'm not worried about the two extra characters. I guess I'm profligate
with electrons :slight_smile:

David

--
Upcoming training from Ruby Power and Light, LLC:
   * Intro to Ruby on Rails, Edison, NJ, October 23-26
   * Advancing with Rails, Edison, NJ, November 6-9
Both taught by David A. Black.
See http://www.rubypal.com for more info!

But magic numbers suck.

···

On Mon, 08 Oct 2007 16:56:11 -0700, William James wrote:

That's a violation of common sense. '%!PS-Adobe' isn't going
to change, and therefore 10 won't need changing.

--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer

Jay Levitt wrote:

That's a violation of common sense. '%!PS-Adobe' isn't going
to change, and therefore 10 won't need changing.

But magic numbers suck.

That would only be true if vendors randomly and unexpectedly changed them. From what I can gather (from Wikipedia and general experience) as formats change vendors may extra add data to the end of the magic number (or create a new one), but always leave the 'base' magic number alone.

Personally, I think you should stop worrying and learn to love the magic number. :slight_smile:

Regards,

Dan

···

On Mon, 08 Oct 2007 16:56:11 -0700, William James wrote:

No, not the magic(5) kind of magic number... :slight_smile: I don't think "%!PS-Adobe"
is changing either. And if it's not changing, then its length will always
be 10.

I'm talking about what wikipedia calls an "unnamed numerical constant". It
took me a few seconds to realize that "10" was the length of "%!PS-Adobe".
Is PS.length (or size, if you prefer) longer to type? Yes. Is it likely
to change? No. Is it more explanatory? Yes. Will it still work when you
copy and paste this code to search for a different magic phrase? Yes.

···

On Tue, 9 Oct 2007 21:19:42 +0900, Daniel Berger wrote:

That would only be true if vendors randomly and unexpectedly changed
them. From what I can gather (from Wikipedia and general experience) as
formats change vendors may extra add data to the end of the magic number
(or create a new one), but always leave the 'base' magic number alone.

Personally, I think you should stop worrying and learn to love the magic
number. :slight_smile:

--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer

I'm talking about what wikipedia calls an "unnamed numerical constant". It
took me a few seconds to realize that "10" was the length of "%!PS-Adobe".
Is PS.length (or size, if you prefer) longer to type? Yes. Is it likely
to change? No. Is it more explanatory? Yes. Will it still work when you
copy and paste this code to search for a different magic phrase? Yes.

Agreed 100%

From a readability standpoint I'd put it in the same category as
using, say, 90 instead of ?Z.

Or using 1246774599 instead of 'JPEG'.unpack("N").

The number of characters typed (golfing aside) shouldn't even enter
into consideration in cases like these.

Regards,

Bill

···

From: "Jay Levitt" <jay+news@jay.fm>