Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Table(var rows: List[Row] = Nil) {
- def add(r: Row) = { rows = r :: rows }
- }
- class Row(var cells: List[Cell] = Nil) {
- def add(c: Cell) = { cells = c :: cells }
- }
- case class Cell(content: String)
- object test {
- def table(init: implicit Table => Unit) = {
- implicit val t = new Table()
- init
- t
- }
- def row(init: implicit Row => Unit)(implicit t: Table) = {
- implicit val r = new Row()
- init
- t.add(r)
- }
- def cell(str: String)(implicit r: Row) =
- r.add(Cell(str))
- val doc = table {
- row {
- cell("test")
- }
- table {
- row {
- cell("test2")
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement