From: Paul McMahon Date: 2007-11-21T15:01:26+09:00 Subject: Re: for loop On Wed, 21 Nov 2007 13:39:58 +0900, Martin Durai wrote: > Thank you carl, iam very new to this language > > sorry carl could you help with this code fully > > for( int i = namespaceEnd -1; i >= 0; i--) { > if( prefix.equals( namespacePrefix[ i ] ) ) { > return namespaceUri[ i ]; > } > > > thank you in advance > You might consider using an array of namespace objects instead of parallel arrays class Namespace attr_reader :prefix, :uri def initialize(prefix, uri) @prefix = prefix @uri = uri end end namespaces = [ Namespace.new("prefix", "uri"), ...] then your code becomes something like: matching_namespace = namespaces.find {|namespace| namespace.prefix == prefix) return matching_namespace ? matching_namespace.uri : nil