dictionary

Scala immutable Map class: methods, examples, and syntax

This page contains a large collection of examples of how to use the Scala Map class. There are currently well over 100 examples.

A Scala Map is a collection of unique keys and their associated values (i.e., a collection of key/value pairs), similar to a Java Map, Ruby Hash, or Python dictionary.

A Scala “Word of the day” shell script

I have a 19" monitor on the counter between my kitchen and living room, and it’s powered by a Raspberry Pi. I use the Linux Phosphor screen saver to show a scrolling “news and stock ticker” on the display, which I’ve programmed to show news from several different sources (Atom and Rss feeds, along with other news and data sources). An old version of the display looks like this:

My Raspberry Pi news ticker display

Today I added a new “Word of the day” feature to the display, and as with all of the other code, I wrote a Scala shell script to generate the output.

How to convert a Java Map to a Scala Map using JavaConverters

Here’s a quick look at how to convert a Java Map (such as HashMap) to a Scala Map using the JavaConverters object:

// import what you need
import java.util._
import scala.collection.JavaConverters._

// create and populate a java map
val jMap = new HashMap[String, String]()
jMap.put("first_name", "Alvin")
jMap.put("last_name",  "Alexander")

// convert the java map to a scala map
val sMap = jMap.asScala

Meaning of the word “reticent”

Today’s word of the day is reticent. Per Google, it means, “Not revealing one’s thoughts or feelings readily. ‘She was extremely reticent about her personal affairs.’”

AppleScript tip: using the ScriptEditor dictionary

If you really dig into AppleScript programming you're eventually going to need to learn what methods you can call on Mac applications. The way you do this is to dig into the ScriptEditor Dictionary. To open the Dictionary, click the File menu, then choose the Open Dictionary menu item. This brings up the following dialog:

Mac OS X dictionary

At least once a week (and more likely once a day) I need to look up the spelling or meaning of a word. Interactive spell-checking is built into many Mac OS X applications (like TextMate), so that saves me when I'm typing. But a cool thing that's also built into many Mac OS X applications is the ability to easily get a dictionary definition for a word in a document.