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 > return type
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
return type

Réponse
 
LinkBack Outils de la discussion
Vieux 21/11/2007, 11h11   #1
Martin Durai
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut return type

Actually the following code is a java return type. could any one to
do the same in ruby.

return processNamespaces ? elUri[depth] : NO_NAMESPACE


Thank you in advance
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 21/11/2007, 14h04   #2
Phrogz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: return type

On Nov 21, 4:11 am, Martin Durai <mar...@angleritech.com> wrote:
> Actually the following code is a java return type. could any one to
> do the same in ruby.
>
> return processNamespaces ? elUri[depth] : NO_NAMESPACE


I don't understand your question.
  Réponse avec citation
Vieux 22/11/2007, 08h47   #3
Martin Durai
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: return type

hi gavin

Iam in a task of porting java class into ruby. so how to port the
following java code into ruby. I didnt understood exactly what java does
with the following code. so could you me to port this one.


public String getNamespace()
{
if(eventType == START_TAG) {
return processNamespaces ? elUri[ depth ] : NO_NAMESPACE;
} else if(eventType == END_TAG) {
return processNamespaces ? elUri[ depth ] : NO_NAMESPACE;
}
return null;
}



Gavin Kistner wrote:
> On Nov 21, 4:11 am, Martin Durai <mar...@angleritech.com> wrote:
>> Actually the following code is a java return type. could any one to
>> do the same in ruby.
>>
>> return processNamespaces ? elUri[depth] : NO_NAMESPACE

>
> I don't understand your question.


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

  Réponse avec citation
Vieux 23/11/2007, 04h11   #4
Phrogz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: return type

On Nov 22, 1:47 am, Martin Durai <mar...@angleritech.com> wrote:
> hi gavin
>
> Iam in a task of porting java class into ruby. so how to port the
> following java code into ruby. I didnt understood exactly what java does
> with the following code. so could you me to port this one.
>
> public String getNamespace()
> {
> if(eventType == START_TAG) {
> return processNamespaces ? elUri[ depth ] : NO_NAMESPACE;
> } else if(eventType == END_TAG) {
> return processNamespaces ? elUri[ depth ] : NO_NAMESPACE;
> }
> return null;
> }


It seems that you don't know what the Java code is doing, and you
don't know how to program in Ruby. I would say you have a lot of work
ahead of you.

Are eventType and processNamespaces and elUri and depth all global
variables? Let's assume so.

The following is valid Ruby code, if you have defined the appropriate
constants:

def getNamespace
if $eventType == START_TAG
return $processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
elsif $eventType == END_TAG
return $processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
else
return nil
end
end

If you don't understand the "a ? b : c" syntax, google for "ternary
operator".

Here is the same code as the above written in increasingly simpler
ways:

def getNamespace
if $eventType == START_TAG || $eventType == END_TAG
return $processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
else
return nil
end
end

def getNamespace
if $eventType == START_TAG || $eventType == END_TAG
$processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
else
nil
end
end

def getNamespace
if $eventType == START_TAG || $eventType == END_TAG
$processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
end
end

def getNamespace
case $eventType
when START_TAG, END_TAG
$processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
end
end

def getNamespace
if [ START_TAG, END_TAG ].include?( $eventType )
$processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
end
end

  Réponse avec citation
Vieux 16/04/2008, 16h01   #5
Juan Ayup
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: return type

Gavin Kistner wrote:
> def getNamespace
> if [ START_TAG, END_TAG ].include?( $eventType )
> $processNamespaces ? $elUri[ $depth ] : NO_NAMESPACE
> end
> end


And of course, the oneliner:

def getNamespace
[ START_TAG, END_TAG ].include?( $eventType ) &&
($processNamespaces ? $elUri[$depth] : NO_NAMESPACE)
end

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

  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 03h03.


É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,15254 seconds with 13 queries