heredoc

Scala multiline strings (heredoc) syntax

Scala FAQ: Can I create multiline strings in Scala, using something like a heredoc syntax?

Technically Scala doesn't refer to it as a heredoc syntax, but you can easily create multiline strings in Scala. All you have to do is enclose each end of your multiline string in three double-quotes, like this:

val foo = """Line 1.
Line 2.
Line 3."""

Here's an example of what this multiline string syntax looks like in a small example Scala application:

Linux shell script heredoc example

I was just working on my Linux Teleport command (Linux cd command with a history), and ran across the code below, which essentially shows how to use a form of "heredoc" syntax in a Bash shell script. This approach uses the Linux cat command, but functions just like the heredoc syntax in languages like Perl.

Here's the source code I just came across:

PHP here document (heredoc) examples

PHP here doc FAQ: Can you share some examples of the PHP "here" doc (heredoc) syntax?

"Here" documents in many languages are provided as a way to address the following problems:

Ruby glob example - preview many image by creating a single HTML file

Every once in a while someone will give me a large collection of images (JPG, PNG, GIF) that I need to either look at or print. On the Mac (and recent versions of Windows) there are now tools to look at a group of images, but I still like a little program that I wrote.

I wrote this program in Ruby, and what it lets you do is combine all of your pictures into one web page. Then, with the use of CSS, the HTML document you create lets you print each image on a separate page.

Syndicate content