Subtracting string arrays

Hello,

I am having am issue subtracting two arrays with string elements.

I have the following?

a = ["StringA", "StringB", "StringC"]

b = ["StringC"]

How to I subtract the two arrays so I have a new array with the
following?

result = ["StringA", "StringB"]

Thanks

···

--
Posted via http://www.ruby-forum.com/.

How to I subtract the two arrays so I have a new array with the
following?

result = ["StringA", "StringB"]

You've almost answered your own question:

a = ["StringA", "StringB", "StringC"]

=> ["StringA", "StringB", "StringC"]

?> b = ["StringC"]
=> ["StringC"]

a - b

=> ["StringA", "StringB"]

Gary Wright

···

On Feb 12, 2010, at 8:43 PM, Brian Scott wrote:

Hi Brian,

if you have the following arrays:

a = ["StringA", "StringB", "StringC"]

b = ["StringC"]

should do the following:

c = a-b
c = ["StringA", "StringB"]

Bye.

Sorry, about my english Tarzan...jeje...

···

--- El vie 12-feb-10, Brian Scott <mr.novell@gmail.com> escribió:

De: Brian Scott <mr.novell@gmail.com>
Asunto: Subtracting string arrays
Para: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Fecha: viernes, 12 de febrero de 2010, 11:43 pm

Hello,

I am having am issue subtracting two arrays with string elements.

I have the following?

a = ["StringA", "StringB", "StringC"]

b = ["StringC"]

How to I subtract the two arrays so I have a new array with the
following?

result = ["StringA", "StringB"]

Thanks
--
Posted via http://www.ruby-forum.com/.

      Yahoo! Cocina

Encontra las mejores recetas con Yahoo! Cocina.