Last active
March 22, 2016 16:11
-
-
Save splattael/e071f987c908584d2c62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error in ./foo.cr:22: undefined method 'uid' for Nil (compile-time type is Rank?) | |
p list.by("foo").uid | |
^~~ | |
================================================================================ | |
Nil trace: | |
./foo.cr:13 | |
def by(uid) | |
^~ | |
./foo.cr:14 | |
@entries.find { |rank| rank.uid == uid } | |
^~~~ | |
/opt/crystal/src/enumerable.cr:218 | |
def find(if_none = nil) | |
/opt/crystal/src/enumerable.cr:222 | |
if_none | |
^~~~~~~ | |
/opt/crystal/src/enumerable.cr:218 | |
def find(if_none = nil) | |
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rank | |
getter uid | |
def initialize(@uid) | |
end | |
end | |
class RankList | |
@entries = [] of Rank | |
def initialize(@entries) | |
@entries | |
end | |
def by(uid) | |
@entries.find { |rank| rank.uid == uid } | |
end | |
end | |
list = RankList.new( | |
[Rank.new("foo")] | |
) | |
p list.by("foo").uid | |
p list.by("bar").uid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment