Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl
Commits
91f52f5f
Commit
91f52f5f
authored
Jan 11, 2011
by
Graham Ritchie
Browse files
if the coderef argument to the contructor is not defined we create an empty iterator
parent
4356fdef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
modules/Bio/EnsEMBL/Utils/Iterator.pm
modules/Bio/EnsEMBL/Utils/Iterator.pm
+15
-6
No files found.
modules/Bio/EnsEMBL/Utils/Iterator.pm
View file @
91f52f5f
...
...
@@ -57,11 +57,13 @@ use warnings;
=head2 new
Arg
1
: a coderef representing the iterator, this anonymous subroutine
Arg
ument
: a coderef representing the iterator, this anonymous subroutine
is assumed to return the next object in the set when called,
and to return undef when the set is exhausted
and to return undef when the set is exhausted. If the argument
is not defined then we return an 'empty' iterator that immediately
returns undef
Example
:
Example :
my $iterator = Bio::EnsEMBL::Utils::Iterator->new(
sub { return $self->fetch_by_dbID(shift @dbIDs) }
...
...
@@ -84,9 +86,16 @@ sub new {
my
$class
=
shift
;
my
$coderef
=
shift
;
die
"
The supplied argument does not look like an coderef
"
unless
ref
$coderef
eq
'
CODE
';
# if the user doesn't supply a coderef, we create a
# simple 'empty' iterator that immediately returns undef
if
(
not
defined
$coderef
)
{
$coderef
=
sub
{
return
undef
};
}
else
{
die
"
The supplied argument does not look like an coderef
"
unless
ref
$coderef
eq
'
CODE
';
}
my
$self
=
{
sub
=>
$coderef
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment