开发者

logger.debug ["This is", "an", "Array"] Rails

Why is my output of

logger.d开发者_StackOverflowebug ["This is", "an", "Array"]

This isanArray

and not something like ["This is", "an", "Array"]

Is there a way to do this? (I know I could do to_yaml, but that is too verbose for me)

What are some options for a nice clean output of an array, similar to print_r in php?


Try this:

logger.debug ["This is", "an", "Array"].inspect

This also works for all other kinds of objects: Hashes, Classes and so on.


you could try the .inspect method....

logger.debug array.inspect

I agree with Andrew that there is nothing wrong with...

puts YAML::dump(object)


When you do that, to_s is automatically called on the array, and that's how to outputs.

Calling to_yaml is by no means verbose. You could also look at using join or inspect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜