turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Function overloads in JSL?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jul 20, 2012 9:22 AM
(2000 views)

Hey,

I've just started working with Functions in JSL. I am wondering if there is a way to create overload functions similar to C++/C#.

Even if JSL doesn't officially support it, there also may be a way to create pseudo overloads, such as with VBScript using CASE / WHERE. Has anyone tried this?

Thanks!

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jul 24, 2012 11:35 AM
(3854 views)

Solution

There's no overloading; however, you can make arguments optional so that, for instance, f(a) and f(a, b) can call the same function:

f = Function({x, y=0}, sqrt(x * x + y * y));

You can also check the types of the arguments with functions like Is Number() within a nested if(), which sounds like your VB example.

2 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jul 24, 2012 11:35 AM
(3855 views)

There's no overloading; however, you can make arguments optional so that, for instance, f(a) and f(a, b) can call the same function:

f = Function({x, y=0}, sqrt(x * x + y * y));

You can also check the types of the arguments with functions like Is Number() within a nested if(), which sounds like your VB example.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jul 24, 2012 12:22 PM
(1927 views)