added if function with tests.
Merge pull request #5 from mattyw/added_if

added if function with tests.