Detect behaviour

0 views
Skip to first unread message

Haruki Zaemon

unread,
Feb 14, 2008, 5:45:43 PM2/14/08
to ambition.rb
I notice that detect seems to return an array. Shouldn't it return
either a single record or nil?

Haruki Zaemon

unread,
Feb 14, 2008, 6:11:03 PM2/14/08
to ambition.rb
Looking into it a little bit further, it seems as though any call to
first returns an Array rather than a single object or nil. Is this the
desired behaviour? It's certainly not what I would have expected.

Here's a possible fix (again I seem to be unable to create a
lighthouse account):

Index: ambition-0.5.0/lib/ambition/api.rb
===================================================================
--- ambition-0.5.0/lib/ambition/api.rb (revision 36)
+++ ambition-0.5.0/lib/ambition/api.rb (working copy)
@@ -37,7 +37,7 @@

def first(count = 1)
sliced = slice(0, count)
- count == 1 ? sliced.kick : sliced
+ count == 1 ? sliced.kick.first : sliced
end

def each(&block)

Chris Wanstrath

unread,
Feb 16, 2008, 5:58:07 AM2/16/08
to ambit...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages