Skip to content

Conversation

@PetrPytelka
Copy link
Contributor

String functions (trim, left, right, mid) - supports null parameter and numerical parameter, improved VB/VBA compatibility

Copy link
Owner

@verhas verhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes, mainly formatting. Other than that genius and also thanks for catching possible NPE-s. It would be nice to have some unit test that covers the execution branch when the Object o is null.

@PetrPytelka
Copy link
Contributor Author

Thank you for your suggestions. I added test on null and also two new functions (CStr and IsNull).

If you will have a minute please review the changes.....

@PetrPytelka PetrPytelka force-pushed the string_functions_with_non_string_param branch from 44c28eb to c8eb9ac Compare January 27, 2020 14:31
@PetrPytelka PetrPytelka requested a review from verhas January 27, 2020 15:37
com.scriptbasic.classification.Utility.class})
static public String ltrim(final String s) {
static public String ltrim(final Object o) throws BasicRuntimeException {
if(o==null) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use proper formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting was fixed.

assert("rtrim", rtrim(v)=" 1234")

' Test null values
assert("ltrim_with_null", IsNull(ltrim(xxx)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of xxx you could use undef. More expressive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed variable name.

@PetrPytelka PetrPytelka force-pushed the string_functions_with_non_string_param branch from c8eb9ac to 1666063 Compare June 9, 2020 20:38
@PetrPytelka PetrPytelka requested a review from verhas June 10, 2020 09:22
@verhas verhas merged commit 7a9facf into verhas:master Jun 16, 2020
@PetrPytelka PetrPytelka deleted the string_functions_with_non_string_param branch June 16, 2020 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants