I have an array of hashes like below.
[
{
"name":"keith",
"age":"20",
"weight":"100lb",
"status":"CURRENT"
},
{
"name":"keith",
"age":"20",
"weight":"110lb",
"status":"PREVIOUS"
},
{
"name":"keith",
"age":"20",
"weight":"120lb",
"status":"FUTURE"
}
]
I am trying to remove a hash based on the condition that if name and age are the same then fetch out the hash that has the status CURRENT ignoring the other statuses PREVIOUS and FUTURE. so the output should be
[
{
"name":"keith",
"age":"20",
"weight":"100lb",
"status":"CURRENT"
}
]
I have tried using group_by and flat_map but couldn't get the desired output.
Could someone please help me in figuring out this?