Logger.debug ["This", "a", "Array"] Rails

Why is my conclusion

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

This isanArray

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

Is there any way to do this? (I know I can do to_yaml, but this is too much for me)

What are some options for pure clean array output similar to print_r in php?

+4
source share
3 answers

Try the following:

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

This also works for all other objects: hashes, classes, etc.

+4
source

you can try the .inspect method ....

 logger.debug array.inspect 

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

 puts YAML::dump(object) 
+1
source

When you do this, to_s automatically called in the array and that how to output.

The call to_yaml no means detailed. You can also see join or inspect .

0
source

Source: https://habr.com/ru/post/1342315/


All Articles