examples

Scala tuple examples and syntax

Scala FAQ: Can you share some examples of using tuples in Scala?

A Scala tuple is a class that can contain a miscellaneous collection of elements. I like to think of them as a little bag or container you can use to hold things and pass them around.

You create a tuple with the following syntax, enclosing its elements in parentheses. Here's a tuple that contains an Int and a String:

Scala for loop syntax examples (including yield and guards)

Scala FAQ: Can you share some examples of the Scala for loop syntax?

Sure. I'm going to start with a comparison to Java for loops, because that's what I was just thinking about.

In Java you might write a for loop like this:

for (int i = 0; i < 10; i++) {
  System.out.println(i);
}

The equivalent for loop in Scala looks like this:

for (i <- 1 to 10) {
  println(i)
}

(The use of parentheses isn't necessary in either example, but most for loops will be longer.)

A collection of Scala flatMap examples

Scala flatMap FAQ: Can you share some Scala flatMap examples?

Sure. When I was first trying to learn Scala, and cram the collections' flatMap method into my brain, I scoured books and the internet for great flatMap examples. Once I had a little grasp of it I started creating my own examples, and tried to keep them simple.

Using flatMap on a list of String

The following examples show the differences between map and flatMap on a sequence of String:

Simple Scala Akka Actor examples (Hello, world examples)

Scala Actors FAQ: Can you share a Scala Akka Actors example/tutorial?

Sure. Most of the Scala Akka Actor tutorials I see jump right into the deep end, throwing you into some tough concepts right away. Personally I'm more into the "crawl before you walk approach", and to that end, here are some simple Akka Actor examples, of the "Hello, world" variety.

A simple Akka "Hello, world" example

My first Akka Actor example is about as simple as I can make it:

JFrame examples and tutorials (collection)

Today is organization day for me, and in an effort to organize everything I've ever written about a Java JFrame, here is a collection of links to all my Java JFrame examples and tutorials.

25+ Drupal form and module programming examples

This page serves as an index to all of my Drupal module, form, and databases tutorials and examples. In an effort to help supplement the documentation on the Drupal.org website, over time I hope to have good examples for every Drupal module and form problem you'll run into.

Apache RedirectMatch wildcard examples

Apache Redirect 301 FAQ: How can I redirect many old web pages using the Apache Redirect or RedirectMatch syntax and wildcard patterns (regex patterns)?

I'm currently trying to fix a lot of URLs that I more or less intentionally broke when I deleted the old "directory" portion of this website. In short, after removing the directory, no URL at "/Dir" work any more, so I have thousands of broken URLs (technically "URIs") that look like this:

Drupal 6 SQL insert examples (and syntax)

Drupal 6 SQL insert FAQ: Can you share an example of how to write a Drupal 6 SQL insert statement?

There are at least two ways to write a SQL insert statement in Drupal 6, and I'll demonstrate both of those here.

A Drupal 6 SQL INSERT example using db_query

The first method involves writing an old-fashioned SQL INSERT statement with the Drupal 6 db_query function, like this:

Searchable Drupal API function examples

Summary: A Drupal API/functions experiment - A searchable collection of Drupal projects to demonstrate Drupal API function examples.

I just started a new Drupal API examples experiment recently. The basic concept is to make it easier for Drupal programmers to be able to find working, real-world Drupal API programming examples as a way to help document the available Drupal API functions.

Linux and Unix examples, commands, and tutorials

This page is an index to the Unix and Linux command tutorials and examples we've created. We've found that while Unix and Linux are powerful operating systems, its cryptic commands can sometimes be hard to remember, so hopefully these "Learn Unix by Example" tutorials will help make your Unix and Linux life easier.

Linux commands, organized by category

To make it easier to find the Linux command tutorials you're looking for, we've broken them down into the following sections:

Syndicate content