PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > compare 2 "arrays"
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
compare 2 "arrays"

Réponse
 
LinkBack Outils de la discussion
Vieux 05/11/2007, 18h04   #1
Christian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut compare 2 "arrays"

Hello,

sorry i'm a beginner with ruby and hanging on
a problem comparing two arrays?

Have anybody an advice what's wrong in my logic, beacuse printing of k
and row2["id"] like
p "#{k} = #{row2["id"]}" works!?

many thanks ,Christian


rows=0
ngs=Array.new

# some thousand id's
FCSV.foreach("#{path}#{part1}",:headers =>true ,:col_sep => "\t") do |
row|
ngs.push(row["id"])
end

# a lot of millions
FCSV.foreach("#{path}#{part2}",:headers =>true ,:col_sep => "\t") do |
row2|
ngs.each do |k|
if k == row2["id"]
p row2
end
end
end



mp_hash.rb:36: undefined local variable or method `found' for
main:Object (NameError)
from cmp_hash.rb:34:in `each'
from cmp_hash.rb:34
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
1429:in `each'
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
990:in `foreach'
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
1162:in `open'
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
989:in `foreach'
from cmp_hash.rb:33

  Réponse avec citation
Vieux 05/11/2007, 20h33   #2
johan.veenstra@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: compare 2 "arrays"

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

On 11/5/07, Christian <ozric@web.de> wrote:

> mp_hash.rb:36: undefined local variable or method `found' for



On line 36 of the source file mp_hash.rb is something called 'found',
but it is not defined.
The same happen with the follwing very short program:

test=found

ruby -w test.rb

test.rb:1: undefined local variable or method 'found' for main:Object
(NameError)

  Réponse avec citation
Vieux 05/11/2007, 21h35   #3
Christian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: compare 2 "arrays"

On 5 Nov., 21:33, johan.veens...@gmail.com wrote:
> Note: parts of this message were removed by the gateway to make it a legal Usenet post.
>
> On 11/5/07, Christian <oz...@web.de> wrote:
>
> > mp_hash.rb:36: undefined local variable or method `found' for

>
> On line 36 of the source file mp_hash.rb is something called 'found',
> but it is not defined.
> The same happen with the follwing very short program:
>
> test=found
>
> ruby -w test.rb
>
> test.rb:1: undefined local variable or method 'found' for main:Object
> (NameError)



arrgh a classical example -
to not see the forest for the trees

thanks christian

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h02.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10877 seconds with 11 queries