add

Scala: How to add, update, and remove elements with a mutable Map

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.15, “How to Add, Update, and Remove Elements with a Mutable Map”

Problem

You want to add, remove, or update elements in a mutable map.

Solution

Add elements to a mutable map by simply assigning them, or with the += method. Remove elements with -= or --=. Update elements by reassigning them.

Given a new, mutable Map:

How to add elements to a List in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.3, “How to Add Elements to a List in Scala”

Problem

You want to add elements to a List that you’re working with.

How to add elements to a List in Scala

Scala List FAQ: How do I add elements to a Scala List?

This is actually a trick question, because you can't add elements to a Scala List; it's an immutable data structure, like a Java String.

How to get tomorrow’s date in Java

Java Date FAQ: How do I determine tomorrow's date in Java?

Many times when you're working with a Java Date, you need to be able to add something to a date, i.e., to get tomorrow's date, or the next week, or the next year. In this short tutorial, we'll demonstrate how to easily add one day to today to get tomorrow's date.

How to add an item to a Perl hash

Perl hash FAQ: How do I add an item/element to a Perl hash?

Answer: Adding an item to a Perl hash is just like creating a Perl hash initially. Just assign the new item to the hash with the correct syntax, and you're in business.

In the following sample code I show how this is done by creating a hash named prices. The hash key is the name of a product, like pizza, and the hash value is the price of that product. Here's my Perl hash sample code:

AppleScript math: Addition, subtraction, multiplication, division

AppleScript math FAQ: Can you show some examples of basic AppleScript math operations, like addition, subtraction, multiplication, and division?

Sure, let's take a look at some AppleScript math examples.

AppleScript addition syntax/examples

To add a few numbers together just use the normal set syntax and the + operator, like this AppleScript addition example:

set one to 1
set two to 2
set answer to one + two
display dialog answer

That example displays the number 3.

cvs binary file example - fix a binary file with cvs admin

Several times when working with CVS I've forgotten to check a binary file into CVS with the binary file flag. Fortunately this problem can be fixed using the cvs admin command. It's just important to remember that fixing this problem is a two-step operation.

How do I add a binary file to a CVS repository?

CVS binary file FAQ - How do I add a binary file to a CVS repository?

Answer: You add a binary file to a CVS repository with the cvs add command, like this:

cvs add -kb myfile.zip