parent

Children Learn What They Live (poem)

If a child lives with criticism,
he learns to condemn.

If a child lives with fear,
he learns to be apprehensive.

If a child lives with ridicule,
he learns to be shy.

If a child lives with shame,
he learns to feel guilty.

If a child lives with encouragement,
he learns to be confident.

If a child lives with praise,
he learns to be appreciative.

If a child lives with acceptance,
he learns to love.

If a child lives with approval,
he learns to like himself.

If a child lives with honesty and fairness,
he learns what truth and justice are.

If a child lives with friendliness,
he learns that the world is a nice place in which to live.

With what is your child living?

~part of a "Children Learn What They Live" poem by Dorothy Law Nolte

How to define a collection whose element are all of some base type (inheritance)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 19.6, “How to define a collection whose element are all of some base type.”

Back to top

Problem

You want to specify that a class or method takes a type parameter, and that parameter is limited so it can only be a base type, or a subtype of that base type.

Back to top

Solution

Define the class or method by specifying the type parameter with an upper bound. To demonstrate this, create a simple type hierarchy:

Table of Contents

  1. Problem
  2. Solution
Back to top

Akka/Scala: How to monitor the death of an Actor with “watch”

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 13.8, “Monitoring the death of an Akka Actor with ‘watch’”.

Back to top

Problem

You want an actor to be notified when another actor dies.

Back to top

Solution

Use the watch method of an actor’s context object to declare that the actor should be notified when an actor it’s monitoring is stopped.

Table of Contents

  1. Problem
  2. Solution
Back to top

How to call a Scala superclass constructor

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 4.11, “How to call a Scala superclass constructor.”

Problem

You want to control a Scala superclass constructor that’s called when you create constructors in a subclass.