Thanks for everyone's response. My problem was that I needed to switch the
'p' and the 'attr' so it was:
attr =~ /#{p}/
attr is something like: "Component.behavior"
p would be something like: "behavior"
Zach
-----Original Message-----
From: David A. Black [mailto:dblack / wobblini.net]
Sent: Wednesday, May 26, 2004 11:17 AM
To: ruby-talk ML
Subject: Re: delete_if woes
Hi --
On Wed, 26 May 2004, Zach Dennis wrote:
> I am having trouble with my delete_if block.
>
> prop_array.delete_if{ |p|
> (p=~/#{attr}/).to_i > 0; }
>
> and i have tried the longer version
>
> prop_array.delete_if{ |p|
> m = (p=~/#{attr}/).to_i
> m > 0; }
>
> and i have tried
>
> prop_array.delete_if{ |p|
> (p=~/#{attr}/) != nil }
>
> It deletes every element, even when m == 0 or m == nil. Any ideas? Thanks,
I'm not sure exactly what you're trying to do. The examples do
different things. Can you give sample before and after arrays? And
what's in attr?
David
--
David A. Black
dblack / wobblini.net
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004