tristanjuricek / knockoff

A Markdown parser + object model in scala
http://tristanjuricek.github.com/knockoff
BSD 3-Clause "New" or "Revised" License
102 stars 17 forks source link

Get Rid Of That Casting Stink #12

Closed tristanjuricek closed 15 years ago

tristanjuricek commented 15 years ago

So we parse a text file into a list of Block objects. This means client code does things like this:

blocks.filter( _.isInstanceOf[ CodeBlock ] )

To get all code blocks. This kind of, well, sucks. Something is wrong here, because it sure seems like my type hierarchy is wrong if we have to cast to do anything useful.

tristanjuricek commented 15 years ago

In version 0.5.0 it's now possible to do things like

( blocks ? Code ).foreach( println )