delete

Scala ArrayBuffer class: methods, syntax, and examples alvin August 16, 2018 - 12:33pm

This page contains a large collection of examples of how to use the Scala ArrayBuffer class.

Use the ArrayBuffer class when you want to use a general-purpose, mutable indexed sequence in your Scala applications:

Scala Array class: methods, examples, and syntax alvin June 16, 2018 - 5:09pm

This page contains a large collection of examples of how to use the methods on the Scala Array class.

Scala List class: methods, examples, and syntax alvin May 22, 2018 - 1:00pm

This page contains a large collection of examples of how to use the methods on the Scala List class.

The Scala List class as an immutable, linear, linked-list class. It’s very efficient when it makes sense for your algorithms to (a) prepend all new elements, (b) work with it in terms of its head and tail elements, and (c) use functional methods that traverse the list from beginning to end, such as filter, map, foldLeft, reduceLeft.

Scala Seq class: methods, examples, and syntax alvin May 21, 2018 - 5:47pm

This page contains a large collection of examples of how to use the methods on the Scala Seq class.

Important note about Seq, IndexedSeq, and LinearSeq

As an important note, I use Seq in the following examples to keep things simple, but in your code you should be more precise and use IndexedSeq or LinearSeq where appropriate. As the Seq class Scaladoc states:

Scala Vector class: method examples and syntax alvin May 20, 2018 - 10:44pm

This page contains a large collection of examples of how to use the Scala Vector class, including most of the methods that are available on a Vector. (Currently over 170 examples.)

How to install and remove Drupal 8 modules at the command line with Composer

I find Drupal 8 module management to be confusing, but one thing I’ve learned is that you can install and remove Drupal 8 modules with Composer at the command line.

Adding a Drupal 8 module with Composer

The short story is that to add a new module — such as the reCAPTCHA anti-spam module — you type this command at the command line (in the root directory of your Drupal 8 website) to install it:

Play Framework: Anorm SQL query syntax and examples

Table of Contents1 - Anorm2 - More background ...3 - A note about my coding style4 - SQL SELECT queries5 - A brief intermission6 - SQL INSERT with primary key (auto increment)7 - SQL INSERT with no primary key8 - SQL UPDATE9 - SQL DELETE10 - Complete example methods11 - A complete class12 - More information

In general the online Play Framework documentation is excellent, but one area where I needed more help was in seeing more examples of the Anorm syntax. To that end, here are some Anorm query examples, taken from a Play Framework application I worked on recently. But first, a little background about Anorm.

How to create a Scala ArrayBuffer (syntax)

As a quick note, this is the syntax for creating a Scala ArrayBuffer:

import scala.collection.mutable.ArrayBuffer

var fruits = ArrayBuffer[String]()
var ints = ArrayBuffer[Int]()

The key thing to know is that the keyword new is not required before the ArrayBuffer. (This is because ArrayBuffer is either defined as a case class, or because it has an apply method defined. I haven’t looked at its source code to know which approach is taken.)