## WeBWorK Problems

### Re: MathObjects Methods

by Danny Glin -
Number of replies: 0
The arrow is used to call a method associated with an object (named by a variable), so when you type "$len->length" you are trying to call the method "length" on the object$len.  Since the variable $len is undefined you get the error you quoted. What you want to do is call the "length" method on$v, i.e. $v->length evaluates to 3 in your example. If you are trying to store that in$len, then what you want is
$len =$v->length;

In terms of how to search for examples using such things, there isn't really any mechanism to do this from within WeBWorK.  If you have command line access to your WeBWorK server you could grep (text search) the OPL for a particular string:
cd /opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary
grep -r "\->length" *
(You need the backslash in front of the - because - is a special character in bash.)

In many cases you can just search for a word, but because "length" is a common term the results you're looking for will probably get lost in all the other hits.

If you don't have command-line access to your WeBWorK server (or for convenience), you can download a copy of the OPL from Github onto your local machine, and then search it from there.  grep is built-in on Macs and Linux.  There is probably a Windows/Powershell equivalent, but I don't know it.