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

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

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 W.

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 S. [email protected] escribió:

De: Brian S. [email protected]
Asunto: Subtracting string arrays
Para: “ruby-talk ML” [email protected]
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs