# String (MathObject Class)

## Contents

### String Class

The String class adds the ability to have special words or phrases be recognized by the MathObjects library. The two pre-defined words are DNE (for "does not exist") and NONE. By default, strings are not case sensitive, so dne and DNE (and Dne, and dNe, etc.) are all considered to be the same thing. The allowed strings are part of the Context, and you can add your own (or remove the two pre-defined ones), and you can make case-sensitive strings if you desire. See the String Context changes section for details. Strings can be used in any Context.

### Creation

   $ans = String("DNE");$ans = Compute("DNE");

$ans = Compute("DNE,NONE"); # a list of strings  ### Answer Checker As with all MathObjects, you obtain an answer checker for a String object via the cmp() method:  ANS(String("DNE")->cmp);  The String class supports the common answer-checker options, and the following additional options: Option Description Default typeMatch =>$object Specifies the type of object that the student should be allowed to enter (determines what constitutes a type mismatch error). Can be either a MathObject or a string that is the class of a MathObject (e.g., "Value::Vector"). 1

If a string answer is used where something other than a number could have been the answer (e.g., as a response to "At what points $$(x,y)$$ is $$\sqrt{x^2+y^2}$$ undefined?"), then you should indicate the type of answer that might be expected when you create the answer checker by setting the typeMatch parameter to an instance of that type. E.g.,

   ANS(String("NONE")->cmp(typeMatch => Point(0,0)));


This will make sure that syntax checking and error messages are appropriate for the kind of answer that the student might submit.

To test for equality of strings, use eq, not ==. (This is a Perl thing.)

### Methods

The String class supports the Common MathObject Methods. There are no additional methods for this class.

### Properties

The String class supports the Common MathObject Properties, and the following additional ones:

Property Description Default
\$r->{caseSensitive} Determines whether or not comparisons to other strings are case sensitive. defined in Context