# \[ANN\] Qo 0.1.6 released - RHA pattern matching added

**URL:** <https://rubytalk.org/t/ann-qo-0-1-6-released-rha-pattern-matching-added/74606>\
**Category:** ruby-talk\
**Created:** [12 April 2018 06:25 UTC](https://rubytalk.org/t/ann-qo-0-1-6-released-rha-pattern-matching-added/74606 "2018-04-12T06:25:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Weaver1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/brandon_weaver1/32/1940_2.png) [@Brandon\_Weaver1](https://rubytalk.org/u/Brandon_Weaver1)\
**Post date:** [12 April 2018 06:25 UTC](https://rubytalk.org/t/ann-qo-0-1-6-released-rha-pattern-matching-added/74606/1 "2018-04-12T06:25:57Z")

</div>

> **[baweaver/qo](https://github.com/baweaver/qo)**
>
> Qo - Query Object - Pattern matching and fluent querying in Ruby

Added a feature for pattern matching with right hand assignment using a  
guarded block implementation. If Qo matches on the left it will run the  
block on the right, otherwise it skips to the next case much like pattern  
matching in more functional languages:

name\_longer\_than\_three = -\> person { person.name.size \> 3 }  
people\_with\_truncated\_names = people.map(&Qo.match\_fn(  
&nbsp;&nbsp;Qo.m(name\_longer\_than\_three) { |person|  
&nbsp;&nbsp;&nbsp;&nbsp;Person.new(person.name[0..2], person.age)  
&nbsp;&nbsp;},  
&nbsp;&nbsp;Qo.m(:\*) # Identity function, catch-all  
))

# And standalone like a case:  
Qo.match(people.first,  
&nbsp;&nbsp;Qo.m(age: 10..19) { |person|  
&nbsp;&nbsp;&nbsp;&nbsp;"#{person.name} is a teen that's #{person.age} years old"  
&nbsp;&nbsp;},  
&nbsp;&nbsp;Qo.m(:\*) { |person|  
&nbsp;&nbsp;&nbsp;&nbsp;"#{person.name} is #{person.age} years old"  
&nbsp;&nbsp;}  
)

Documentation has also been greatly expanded. Let me know if you'd like to  
see any more examples!

- baweaver
