Skip to content

Instantly share code, notes, and snippets.

@AOrobator
Created February 13, 2018 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AOrobator/395d47c4bdba9c6c0682deee87c76d85 to your computer and use it in GitHub Desktop.
Save AOrobator/395d47c4bdba9c6c0682deee87c76d85 to your computer and use it in GitHub Desktop.
class RealmSongRepository: SongRepository {
override fun getSongById(songId: SongId) : Song? = when (songId) {
is ValidSongId -> getSongFromRealm(songId.id) // smart cast to ValidSongId
InvalidSongId -> null
// No else statement required because the compiler knows we’ve covered all cases
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment