06 Nov, 2006

Published at 07:09PM

Tagged with ruby, rails, and reflection

This post has 0 comments

Mixing in some additional fun

I don’t know Ruby extremely well, but I get it. It’s really fun to learn, and I often find additional pleasure from trying to “out do” my previous code. Ruby gives you that luxury. There are so many ways to do the same thing. I know I don’t use the best methods, and so I like figuring out new, more efficient one’s.

For instance, when collecting my del.icio.us bookmarks I used to do an overzealous loop, authenticating and parsing xml using REXML (even keeping track of indexes for the arrays!). I knew this wasn’t the best way to do it, but I was learning and it worked. Now, I collect the bookmarks via one line:

bookmarks = r.recent('tag-name',per_page).sort_by {|post| post['time']}

Then I do a .reverse loop to get the list in reverse chronological order. The first method required 25 lines. The second method required 7 lines. Anyway, there’s still so much to learn. That is definitely a language I enjoy playing around with.

Oh, yeah. At work I’m doing C# until January. Here is one more example/reason why I can’t wait to get back to RoR: Ruby vs. C#. Which would you rather do? It’s things like this that make it hard to switch and try out something else.

Comments

Do you have something to say about this post?
Retype the image to the right Spam Hint: Are You Human? Textile Formatting Tips

or

Ryan Heath | Site Management A Ruby on Rails production.

This site is a Formed Function. Formed Function LLC | @formedfunction | Get in Touch