Print Arrays, Hashes etc in a readable format?
-
Is there a way to output an Array, Hash etc in the Console in a more readable way?
So that items are listed on each their line and indents as the object nests? -
myarray.sort.join("\n") from the console works great.
For hashes, take your pick of .each, each_key, each_pair, and so on.
Read up on the Enumerable class.
-
Ok. I was just checking that there wasn't a built-in function that printed objects, like what you get in PHP with print_r.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement