Blog

BoxLang: Functional Binding to Member Methods

Maria Jose Herrera August 28, 2024

Spread the word

Maria Jose Herrera

August 28, 2024

Spread the word


Share your thoughts

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.

BoxLang Ticket

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.

Try BoxLang

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]

BoxLang Ticket

Happy coding!

Add Your Comment

Recent Entries

The Hidden Costs of In-House Database Management

The Hidden Costs of In-House Database Management

The Hidden Costs of In-House Database Management


Opting for in-house database management involves more than just a salary. Here are some often-overlooked costs associated with maintaining your own DBA team.



1. High Salaries and Benefits


Hiring skilled DBAs is expensive. According to industry reports, the average salary of a DBA in the U.S. can range from $85,000 to over $130,000 per year, depending on experience and expertise. When you add ...

Cristobal Escobar
Cristobal Escobar
November 20, 2024
5 Signs It’s Time to Modernize Your ColdFusion / CFML Application

5 Signs It’s Time to Modernize Your ColdFusion / CFML Application

ColdFusion has long been a reliable platform for building web applications, but like any technology, it requires maintenance and modernization over time. Whether you're using Lucee or Adobe ColdFusion, it’s critical to recognize the signs that your application is no longer meeting today’s standards in performance, security, and scalability. Let’s explore five clear indicators that it’s time to modernize your ColdFusion application and how ColdFusion consulting can help breathe new life into y...

Cristobal Escobar
Cristobal Escobar
November 19, 2024
ColdBox Free Tip 5 - Building Named Routes with a Struct

ColdBox Free Tip 5 - Building Named Routes with a Struct

**Did you know ColdBox provides flexible ways to build routes using structs?** In this tip, we’ll cover how to use the `event.buildLink()` and `event.route()` methods for named routes, a feature that’s especially handy when working with dynamic URLs.

Maria Jose Herrera
Maria Jose Herrera
November 19, 2024