Streamline your code with smooth method referencing!
We’re excited to unveil a new feature that makes method referencing in BoxLang even smoother. Building on our recent update introducing functional static binding to built-in functions, we're now bringing the same ease to member methods.
What’s New?
With this update, you can now directly bind to member methods without the fuss of declaring closures. This means you can streamline your code and make it more readable.
For example, instead of using closures like this:
pendingOrders.each(order => order.submit())
You can now simply use:
pendingOrders.each(.submit)
How Does It Work?
By prefixing your method name with a period (.), you can reference member methods without needing to bind them to a specific instance. This makes your code more concise and eliminates extra boilerplate. Plus, if your methods require arguments, you can pass them like this:
[ "brad", "luis", "jon" ].map(.left(1)) // [ "b", "l", "j" ]
Here, .left(1)
is used to call the left
method on each string in the array, stripping one character from each name.
Why This Matters
This feature not only simplifies method binding but also keeps your code clean and expressive. It’s all about making your development experience smoother and more intuitive.
Want to dive deeper into this feature? Check out the details in our ticket: [BL-351]
Happy coding!
Add Your Comment