From: Eero Saynatkari Date: 2006-10-29T05:19:53+09:00 Subject: Re: How to understand why object is not collected? --yahdd2r5OMEJJ+pI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2006.10.29 03:26, Victor Zverok Shepelev wrote: > Hi all. >=20 > Here's a problem. >=20 > I have some object of MyClass with complex "freeing" logic, and I want to > test this logic. > =20 Hard to say what is going wrong but the solution is simple. Whenever you have a resource that must be released, do it explicitly. The way this is usually implemented is either: f =3D File.open 'foo' puts f.read f.close Or, more conveniently File.open('foo') {|f| puts f.read} The block-form uses ensure to make sure the file handle gets closed. --yahdd2r5OMEJJ+pI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFQ7rR7Nh7RM4TrhIRAhX7AKCsmDzd6YaBLK2PbYY/e3DgmUnJLwCfbi0D pwot24z9lJSVP0kb+WNM+Rw= =wGC0 -----END PGP SIGNATURE----- --yahdd2r5OMEJJ+pI--