Carlos Hernandez Navarro
29 Jun 2020
•
0 min read
Today, I would like to share a small code tip with you.
We are working on designing a new discount system for an online shop. To calculate our discount we are going to use an external library provided by an external company. The external function is working with integers but in our system we are using strings. How can we integrate them?
In this case, we can parse our parameters from string to integer. However, this process is dangerous, so we are using Either to identify and catch possible errors. Lastly, we can use a map2 function to map the value onto the external function. See the results below:
Carlos Hernandez Navarro
Programmer analyst with 3 years of work experience. For the last year, I have been designing a high performance analyst application for an aeronautical company. The main technologies used on this project are: Java Spring boot, kubernete (Openshift), Kafka, Jenkins and Oracle.
See other articles by Carlos
Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ
108 E 16th Street, New York, NY 10003
Join over 111,000 others and get access to exclusive content, job opportunities and more!