function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Miao (Wilson) LiuMiao (Wilson) Liu 

New functional library for Apex

Hi guys,
We just created a library named R.apex, which helps simplify the common tasks in apex code development by adopting a functional style.
It offers tons of utility functions to work with lists, sets, maps and sobjects, making apex code clean and readable. We were suffering from the pain points of writing similar Apex code to complete trivial tasks once and once again, and that is the reason why we want to stop that and start to write reusable code. Here are some examples of what R.apex can do:
 
// Reverse a list
List<Integer> reversedList = R.of(new List<Integer>{ 1, 2, 3 })
    .reverse()
    .toIntegerList();
 
// Fina specific account
List<Account> accountList = ...;
Account acc = (Account)R.of(accountList)
    .find(R.whereEq.apply(new Map<String, Object>{
        'LastName' => 'Wilson',
        'IsDeleted' => false
    }))
    .toSObject();

Hopefully R.apex can help make your Apex code development easier, and you are always welcome to give feedback so that we can improve it.

R.apex is an open source project hosted at https://github.com/Click-to-Cloud/R.apex/.
You can check it out. Feel free to clone it, make changes or submit a PR.

^_^
Leonardi KohLeonardi Koh
Looks interesting, the name of the library however may have an... unfortunate implication.
Elkin CordobaElkin Cordoba
Hi Miao,Thank you for your valuable work. I have started recently to learn functional programming and all the apex libraries that you created around R.apex look so interesting. I will try to use it as soon as possible.
 
Alain CabonAlain Cabon
Hi,

1) Amazing tools (not just R, Sweet Apex, Query, etc). https://github.com/Click-to-Cloud

2) I found your github page from this famous list awesome-salesforce:  https://github.com/mailtoharshit/awesome-salesforce

3) I used R for this question but I am not sure that is the better solution by using R:
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005qhDQAQ

Thanks.
Alain CabonAlain Cabon
(the best solution, sorry for my broken english)
Miao (Wilson) LiuMiao (Wilson) Liu
3) Excellent solution for that case, good job
Alain CabonAlain Cabon
Hi Miao, 

Thanks very much indeed for your feedback.

Alain