Answer the question
In order to leave comments, you need to log in
How to optimize and shorten the code (hash parsing in ruby)?
Actually here is a link to the code REPL.it
There is a hash:
[
{
part: 'one',
books: {
rowling: {book: 'Harry Potter', year: 1997},
martin: {book: 'Game of Thrones', year: 2011},
}
},
{
part: 'two',
books: {
rowling: {book: 'Harry Potter', year: 1997},
martin: {book: 'Game of Thrones', year: 2011},
tolkin: {book: 'The Lord of the Ring', year: 2001}
}
},
]
# Expect Result Output после uniq и сортировки по author
{:author=>:martin, :book=>"Game of Thrones"}
{:author=>:rowling, :book=>"Harry Potter"}
{:author=>:tolkin, :book=>"The Lord of the Ring"}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question