\n on windows?


#1

improper output:
irb(main):034:0> YAML::dump m
=> “— !ruby/object:MailTruck \ndriver: Harold\nroute: \n- 12 Corrigan
Way\n- 2
3 Antler Ave\n”
irb(main):034:0>

expected output:
irb(main):033:0> YAML::dump m
— !ruby/object:MailTruck
driver: Harold
route:

  • 12 Corrigan Way
  • 23 Antler Ave
    irb(main):034:0>

Is this an issue with cmd.exe or irb?
Anyone know how to fix this situation?


#2

On 2/19/06, Alex C. removed_email_address@domain.invalid wrote:

driver: Harold
route:

  • 12 Corrigan Way
  • 23 Antler Ave
    irb(main):034:0>

Is this an issue with cmd.exe or irb?
Anyone know how to fix this situation?

neither. irb was showing you the return value of your function call
effectively, p whatever

try:
puts(YAML::dump(m))


#3

On 2/19/06, Gregory B. removed_email_address@domain.invalid wrote:

— !ruby/object:MailTruck
effectively, p whatever

try:
puts(YAML::dump(m))

poof!
I love it when bugs just evaporate.


#4

DÅ?a Pondelok 20 Február 2006 04:09 Gregory B. napísal:

neither. irb was showing you the return value of your function call
effectively, p whatever

try:
puts(YAML::dump(m))

Meh. So gruesomely verbose :stuck_out_tongue_winking_eye: Quoting yaml.rb:

#
# ryan:: You know how Kernel.p is a really convenient way to dump 

ruby
# structures? The only downside is that it’s not as legible
as
# YAML.
#
# _why:: (listening)
#
# ryan:: I know you don’t want to urinate all over your users’
namespaces.
# But, on the other hand, convenience of dumping for
debugging is,
# IMO, a big YAML use case.
#
# _why:: Go nuts! Have a pony parade!
#
# ryan:: Either way, I certainly will have a pony parade.
#

(Definition of Kernel#y follows.)

Use:
y m

David V.
Having a pony parade