[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Analyze ruby conditional expression

Gábor Sebestyén

2/8/2009 10:04:00 AM

Hi,

I want to examine conditional expressions and I'm looking for tools to do i=
t.
It would be perfect to do it purely in ruby or even in jruby.

Any recommendations are apprecitated.

G=E1bor

5 Answers

Robert Dober

2/8/2009 10:44:00 AM

0

On Sun, Feb 8, 2009 at 11:03 AM, G=E1bor Sebesty=E9n <segabor@gmail.com> wr=
ote:
> Hi,
>
> I want to examine conditional expressions and I'm looking for tools to do=
it.
> It would be perfect to do it purely in ruby or even in jruby.
>
> Any recommendations are apprecitated.
>
> G=E1bor
>
I am not sure what a conditional expression is, care to give some examples?
Robert

Robert Klemme

2/8/2009 12:33:00 PM

0

On 08.02.2009 11:03, Gábor Sebestyén wrote:
> I want to examine conditional expressions and I'm looking for tools to do it.

What exactly does "examine" mean in this context? If you want to
execute them and see results or execute parts of them, why is IRB not
sufficient?

Cheers

robert

Gábor Sebestyén

2/8/2009 6:22:00 PM

0

For instance, I want to decide whether the conditional expressions of
two subsequent IFs are the same (or equivalent). I know it's not easy
in most cases.

Let's see a primitive example:

if A then
do_something1
end

if B
do_something2
end

If A and B equals their conditional branches could be joined.

I'm investigating how it would be easy evaluate A and B whether they
are both true or false.
I need this in my refactoring experiment.

G=E1bor

On Sun, Feb 8, 2009 at 11:43 AM, Robert Dober <robert.dober@gmail.com> wrot=
e:
> On Sun, Feb 8, 2009 at 11:03 AM, G=E1bor Sebesty=E9n <segabor@gmail.com> =
wrote:
>> Hi,
>>
>> I want to examine conditional expressions and I'm looking for tools to d=
o it.
>> It would be perfect to do it purely in ruby or even in jruby.
>>
>> Any recommendations are apprecitated.
>>
>> G=E1bor
>>
> I am not sure what a conditional expression is, care to give some example=
s?
> Robert
>
>

Robert Klemme

2/9/2009 8:51:00 AM

0

2009/2/8 G=E1bor Sebesty=E9n <segabor@gmail.com>:
> For instance, I want to decide whether the conditional expressions of
> two subsequent IFs are the same (or equivalent). I know it's not easy
> in most cases.
>
> Let's see a primitive example:
>
> if A then
> do_something1
> end
>
> if B
> do_something2
> end
>
> If A and B equals their conditional branches could be joined.
>
> I'm investigating how it would be easy evaluate A and B whether they
> are both true or false.
> I need this in my refactoring experiment.

You are aware that expressions A and B can have side effects which
makes it practically impossible to decide on the equivalence? Keep in
mind that Ruby is not a pure functional language.

Cheers

robert

--=20
remember.guy do |as, often| as.you_can - without end

Dylan Evans

2/9/2009 10:07:00 AM

0

On Mon, Feb 9, 2009 at 4:22 AM, G=E1bor Sebesty=E9n <segabor@gmail.com> wro=
te:

> For instance, I want to decide whether the conditional expressions of
> two subsequent IFs are the same (or equivalent). I know it's not easy
> in most cases.
>
> Let's see a primitive example:
>
> if A then
> do_something1
> end
>
> if B
> do_something2
> end
>
> If A and B equals their conditional branches could be joined.
>
> I'm investigating how it would be easy to evaluate whether A and B
> are both true and/or false.
> I need this in my refactoring experiment.
>
> G=E1bor
>

if A && B then
"bingo"
elsif(A) then
"bango"
elsif(B)
"bongo"
else
nil
end

This is just a guess, but you could also use a nested if or a case.
case(a)
when !a | b then "a=3Dt, b=3Dt"
when !(a & b) then "a=3Dt, b=3Df"
when !(a | b) then "a=3Df, b=3Dt"
when !a & b then "a=3Df, b=3Df"
end

But that would be wierd.

case(


> On Sun, Feb 8, 2009 at 11:43 AM, Robert Dober <robert.dober@gmail.com>
> wrote:
> > On Sun, Feb 8, 2009 at 11:03 AM, G=E1bor Sebesty=E9n <segabor@gmail.com=
>
> wrote:
> >> Hi,
> >>
> >> I want to examine conditional expressions and I'm looking for tools to
> do it.
> >> It would be perfect to do it purely in ruby or even in jruby.
> >>
> >> Any recommendations are apprecitated.
> >>
> >> G=E1bor
> >>
> > I am not sure what a conditional expression is, care to give some
> examples?
> > Robert
> >
> >
>
>


--=20
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum