[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

puts from #!, but with data structure chrome

Greg Willits

10/25/2007 9:33:00 AM

When playing with small scripts and using puts to output some results, I
find it rather disappointing that outputting an array or hash does not
have the data structure chrome of [ ] and { } -- I know IRB does this,
but I'm testing stuff too cumbersome for IRB.

Is there a way to run a #! script and cause output using puts (or
alternative) to actually show an array like ['a', 'b'] instead of just
ab ?

-- gw
--
Posted via http://www.ruby-....

5 Answers

Stefano Crocco

10/25/2007 9:41:00 AM

0

Alle giovedì 25 ottobre 2007, Greg Willits ha scritto:
> When playing with small scripts and using puts to output some results, I
> find it rather disappointing that outputting an array or hash does not
> have the data structure chrome of [ ] and { } -- I know IRB does this,
> but I'm testing stuff too cumbersome for IRB.
>
> Is there a way to run a #! script and cause output using puts (or
> alternative) to actually show an array like ['a', 'b'] instead of just
> ab ?
>
> -- gw

Use p instead of puts. puts(obj) calls obj.to_s, while p(obj) calls p.inspect,
which is what IRB does.

I hope this helps

Stefano

Greg Willits

10/25/2007 9:49:00 AM

0

Stefano Crocco wrote:
> Alle giovedì 25 ottobre 2007, Greg Willits ha scritto:
>> Is there a way to run a #! script and cause output using puts (or
>> alternative) to actually show an array like ['a', 'b'] instead of just
>> ab ?
>
> Use p instead of puts. puts(obj) calls obj.to_s, while p(obj) calls
> p.inspect,
> which is what IRB does.
>
> I hope this helps
>
> Stefano


Ahhh. Perfect. :-)

-- gw
--
Posted via http://www.ruby-....

Peña, Botp

10/25/2007 9:49:00 AM

0

from: Greg Willits [mailto:lists@gregwillits.ws]
# Is there a way to run a #! script and cause output using puts (or
# alternative) to actually show an array like ['a', 'b'] instead of just
# ab ?

> a
=> [1, 2]

> b
=> {1=>2, 2=>3}

> p a,b
[1, 2]
{1=>2, 2=>3}

> puts a.inspect, b.inspect
[1, 2]
{1=>2, 2=>3}


in ruby1.9, you can do

puts a.to_s, b.to_s

and p now returns array result (amazing) like,

> RUBY_VERSION
=> "1.9.0"

> p a,b
[1, 2]
{1=>2, 2=>3}
=> [[1, 2], {1=>2, 2=>3}]

> x=(p a,b)

> p x
[[1, 2], {1=>2, 2=>3}]
=> [[1, 2], {1=>2, 2=>3}]

nice for debugging/testing.

kind regards -botp

Anim8rFSK

7/28/2013 3:30:00 AM

0

In article
<ijball-NO_SPAM-1543BE.16355027072013@news.eternal-september.org>,
"Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:

> In article <kt1dbp$8bh$1@speranza.aioe.org>,
> Lord Vader III <lord.vader.iii@gmail.com> wrote:
>
> > On 7/27/2013 1:05 PM, David wrote:
> > > http://www.deadline.com/2013/07/tca-nbc-trying-to-keep-jay-leno-...
> > > d-
> > > post-february/
> > >
> > > TCA: NBC Trying To Keep Jay Leno In The Fold Post February
> > > By NELLIE ANDREEVA
> > >
> > > NBC brass are not just buying Jay Leno a watch, sending him off to
> > > retirement. ?We have been having conversations, talking about various
> > > ideas? for Leno to stay on NBC after he ends his run on The Tonight
> > > Show in February,? NBC topper Bob Greenblatt said today.
> >
> > Sounds like Conan all over again.
>
> Yep. They're complete idiots if they think Jay will stick around after
> this. He'll either (mostly) retire, or another net will pick him up...

It's more of NBC struggling to drive viewers away. Besides, didn't they
notice that Leno's forays into programming other than The Tonight Show
were dreadful and disastrous?

--
Wait - are you saying that ClodReamer was wrong, or lying?

Bill Steele

7/29/2013 7:21:00 PM

0

In article <anim8rfsk-F3EF40.20300827072013@news.easynews.com>,
anim8rFSK <anim8rfsk@cox.net> wrote:

>
> It's more of NBC struggling to drive viewers away. Besides, didn't they
> notice that Leno's forays into programming other than The Tonight Show
> were dreadful and disastrous?

It was dreadful and disastrous to try to do a talk show at 10 p.m. I'd
love to see Jay do a real variety show, with sketch comedy -- get the
young standups to do something besides standup, maybe pick up some of
those people who are getting ready to leave SNL. Just no Japanese
singing duos...