Skip to content

Conversation

zihuaweng
Copy link

Fixes #1050

Copy link
Collaborator

@nhachicha nhachicha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zihuaweng Thanks for your contribution, as mentioned in the comments above there are issues with your implementation (at least for findLast_limit and findRandom_limit), findFirst(limit) could be added best as an extension method for example.

}

RealmResults<E> results = findAll();
Collections.shuffle(results);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shuffle is not supported by 'RealmResults' or 'OrderedRealmCollectionSnapshot', this will throw a UnsupportedOperationException at runtime.

}

RealmResults<E> results = findAll();
results = results.subList(Math.max(results.size() - limit, 0), results.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java.util.SubList cannot be cast to io.realm.RealmResults, this will throw ClassCastException at runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New feature: findLast(int), findFirst(int), findRandom(int)

3 participants