improved error message for missing key

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@5870 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
mihaylov 2006-03-01 17:11:47 +00:00
parent 6fc953bb39
commit 81cff3bbfc
1 changed files with 3 additions and 3 deletions

View File

@ -53,7 +53,7 @@ trait Map[A, +B] extends AnyRef with PartialFunction[A, B] with Iterable[Pair[A,
* @return the value associated with the given key.
*/
def apply(key: A): B = get(key) match {
case None => default
case None => default(key)
case Some(value) => value
}
@ -174,7 +174,7 @@ trait Map[A, +B] extends AnyRef with PartialFunction[A, B] with Iterable[Pair[A,
* The method implemented here yields an error,
* but it might be overridden in subclasses.
*/
def default: B =
error("key not found")
def default(key: A): B =
error("key not found: " + key)
}