OPERATORS

Hash pair (=>)

Associate a key with its value in a hash literal.

Syntax

Signature
{ key => value [, key => value ...] }

Description

Associate a key with its value in a hash literal. Use { => } for an empty hash.

Example

Hash_pair.prg
PROCEDURE Main()

   LOCAL hFare := { "adult" => 2400, "child" => 1200 }
   LOCAL hBooking := { "adult" => 2, "child" => 1 }
   LOCAL nTotal := 0
   LOCAL cType

   FOR EACH cType IN { "adult", "child" }
      nTotal += hFare[ cType ] * hBooking[ cType ]
   NEXT
   QOut( "Booking total in cents", nTotal )

   RETURN

Output