Take a safer head of a YAMLListNode
authorChristos KK Loverdos <loverdos@gmail.com>
Wed, 26 Oct 2011 08:13:29 +0000 (11:13 +0300)
committerChristos KK Loverdos <loverdos@gmail.com>
Wed, 26 Oct 2011 08:13:29 +0000 (11:13 +0300)
logic/src/main/scala/gr/grnet/aquarium/util/yaml/YAMLListNode.scala

index 313742a..a77511f 100644 (file)
@@ -10,7 +10,10 @@ case class YAMLListNode(list: List[YAMLNode]) extends YAMLNode {
   override def listValue = list
   override def isList = true
 
-  def head = YAMLNode(list.head)
+  def head = list match {
+    case Nil    => YAMLEmptyNode
+    case h :: _ => h
+  }
   def tail = YAMLListNode(list.tail)
 
   override def isEmpty = list.isEmpty