Peña, Botp
2/19/2009 7:54:00 AM
From: Joel VanderWerf [mailto:vjoel@path.berkeley.edu]=20
# Has anyone ever felt the need for something like
#=20
# a =3D %t{
# a b c
# d e f
# } # =3D=3D> [["a", "b", "c"], ["d", "e", "f"]]
now the invisible ink (newline) has power :) (cp dblack)
=20
# It's probably too special (this is the first time in 8 years=20
# I've wanted=20
# it), and it is easy to implement it as a method rather than a literal:
#=20
# def table s
# s.split("\n").map!{|t|t.split}
# end
now that is cool
=20
# t =3D table %q{
^^^^
what is w the backquote?
# a b c
# d e f
# }
#=20
# p t # =3D=3D> [["a", "b", "c"], ["d", "e", "f"]]
on my case i get a,
#=3D> [["\\"], ["a", "b", "c"], ["d", "e", "f"]]
had to do this instead,
> table %q{ a b c
d e f
}
#=3D> [["a", "b", "c"], ["d", "e", "f"]]
=20
but it's still untamed,
> table %q{ a b c
d e f
}
#=3D> [["a", "b", "c"], ["d", "e", "f"], []]
i prefer instead the here-doc
> table <<HERE
a b c
d e f
HERE
#=3D> [["a", "b", "c"], ["d", "e", "f"]]
and you can indent it
> table <<-HERE
a b c
d e f
HERE
#=3D> [["a", "b", "c"], ["d", "e", "f"]]