anti-xml icon indicating copy to clipboard operation
anti-xml copied to clipboard

asInstanceOf in LinkedOrderPreservingMap throws ClassCastException

Open gneuvill opened this issue 12 years ago • 0 comments

Hi,

  def syncElems(e1: Elem, e2: Elem): Elem = {
    val fullAttrs = e1.attrs.filterNot(_._2.isEmpty)
    val newAttrs = e2.attrs.filterNot(
      at => fullAttrs.keys exists (at._1 == _)).filter(
      at => e1.attrs.keys exists (at._1 == _))
    e1.copy(attrs = fullAttrs ++: newAttrs)
  }

throws a CastClassException while

  def syncElems(e1: Elem, e2: Elem): Elem = {
    val fullAttrs = e1.attrs.filterNot(_._2.isEmpty)
    e1.copy(attrs = fullAttrs ++: e2.attrs.filterNot(
      at => fullAttrs.keys exists (at._1 == _)).filter(
      at => e1.attrs.keys exists (at._1 == _)))
  }

works fine.

Thanks,

G.N

gneuvill avatar May 06 '12 11:05 gneuvill