Collections

Enumerable is a mixin  that allows you to traverse  a collection. Although they are all pretty exciting `each_with_object` is one of the more exciting ruby enumerables. Basically it does exactly what is says on the tin, it works just like each, but passes the current element and the object to the block every time it iterates.

Let’s demonstrate a very simple example, say we want to count the number of occurrences of every word in a collection;

my_array = %w(rails girls rock rails girls rock rails girls rock always)
=> [“rails”, “girls”, “rock”, “rails”, “girls”, “rock”, “rails”, “girls”, “rock”, “always”]

my_array.each_with_object(Hash.new(0)) { |word, count| count[word] += 1}
=> {“rails”=>3, “girls”=>3, “rock”=>3, “always”=>1}

ta-da and you’re done! Psst word is the word you’d get in a normal each, and count is the object referred to by using with_object (so, the hash). Just a reminder Hash.new(0) sets default value for any key to 0, while {} sets it to nil

Hope to see you at Rails Girls BNE (21/22 July /17) 🙂

Hello world!

Hi and welcome to the Rails Girls BNE website

Rails Girls is an international community dedicated to introducing women to software development in a safe and inclusive environment. We run a workshop in Brisbane biannually. It takes place over two days – Friday evening and a full day workshop on Saturday. We have mentors from the Rails community, as well as other people interested in supporting the event who bring a range of skills. We have recently added a second track (Rails Girls Next) for the not so beginners attendees.

Some of our attendees go on to pursue programming full time – they’ve also come back to mentor others which perpetuates the inclusive nature of the event and the growth of the community. It’s an amazing community that fosters learning and empowers the attendees.

We have had six Rails Girls events in Brisbane since June 2013, and we’re keen to keep them going.

Our website has been developed to complement the learnings at the Rails Girls workshops. We currently focus on Ruby tips, Rails stuff, Sinatra, and everything in-between. We want lots of comments and feedback so we can continue to blog and schedule new events about things you want to hear about.