From: niklas | brueckenschlaeger Date: 2010-12-01T22:52:17+09:00 Subject: Re: Object#each ? --=-hloQMiaHLea3p74FV9A0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Consider code like this: def do_sth_on(this) if this.kind_of?(Enumerable) this.map {|item| do_sth_on(item) } else # whatever end end This is a method that either works on a collection or on single item. As soon as a you make Object behave like Enumerable, this breaks and leads to recursion. Always very dangerous to modify core classes and in this case it seems suicidal :) -- niklas On Wed, 2010-12-01 at 02:44 +0900, Andrew Wagner wrote: > A weird idea just popped into my head: >=20 > class Object > def each > yield self > end > end >=20 > Lets you enumerate without having to worry about whether or not you have = a > collection. Thoughts? Hidden ramifications? --=-hloQMiaHLea3p74FV9A0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAABAgAGBQJM9lMKAAoJEIQdQGZOjo82P0EQAKBLyyPtiRSHnbsPdjR7R9oF 3lR2xMFNL4Ut2N3C+S/2b3oUXi92FCKiEW6lyR+cgULixFulLG4zxafvz/lTpAK4 8pv9gX5ilvYq5ffJru2LsCTOUP8pBZav9Az3oT7xBLwjgrliLhQ+qeYqVF0Brh5b xVY5NgyFlxRU/lv6fePNfEhSfp+7WMcwYW1ShlEiE9bfDPw0rzUYmUOJMej07hfe ffe9/n661TcKu6VE0BMGUeNHPNE9qmtEeThfJUkckVEGjKGI5efwSjA/Dy5Holtf XzKZlQguZ8HkysOTOEVU/cV91eh70WW4urxUAEtJ2+SfjsAzJhC2P+Pi1AThs4xK jPoUGg5cX5SXu50alAljrBl7pPcbWff4Bnr+IxIpkTCI3hRKLGTtazUlOOR7yVt/ oPCRJdkhok1cIRLhEWhsiqM1ypS5A6iQoenYGVH3pp58/zHniVDKEJGLeeaVGfLH bqDU4L7/0tbbaqTNRVMzyuMwxi2kEk6tBuCSjm8r0l2E6MhFRWli5s+7AaY6VnkC Nt/9SHhXgU2DCJ8tM6CjW1XH/OF/j5dNcxT1sZsznUXmo6lSx/WuwiPyaBjlCytk 7rbcy8V37KAvaR5ZOpt5xonWevicBw59QUkbouytpZRX3BD/DIbq0erA/XBWe7O4 ttRDV9dZwN+kGNajCvcI =NXFK -----END PGP SIGNATURE----- --=-hloQMiaHLea3p74FV9A0--