Remove another-take-on-monads
article thumbnail

Kotlin Context Receivers: A Comprehensive Guide

Rock the JVM

toJson (): String } Here, we introduced another characteristic of extension functions. Make sure you have Kotlin version 1.8.22 or later installed before proceeding. 132 - kotlin context receivers.mp4 We’ll use nothing more than the Kotlin standard library this time on top of Java 19. Context receivers are still an experimental feature.

Scala 52
article thumbnail

WebSockets in Http4s

Rock the JVM

WebSocket Implementation To implement the WebSocket in Http4s, we’ll need to add another route in Routes.scala as follows: import org.http4s.server.websocket.WebSocketBuilder2 import fs2.Stream The wsb.build() method takes two arguments, receive of type Pipe[F, WebSocketFrame, Unit] , and send of type Stream[F, WebSocketFrame].

Scala 94
Insiders

Sign Up for our Newsletter

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

article thumbnail

Functional Error Handling in Kotlin, Part 2: Result and Either

Rock the JVM

The CurrencyConverter is a class that converts amounts from one currency to another one. This function takes a lambda that will be executed if the Result is a failure. Kotlin defines two different smart constructors for that: val appleJob : Result = Result. C’est la vie. It’s not that hard to define such an extension function: fun T.

Scala 71
article thumbnail

Scala as a Junior Developer

Rock the JVM

If you want to learn Scala well and fast, take a look at my Scala Essentials course at Rock the JVM. That’s another benefit of the functional programming approach: it is easier to reason about the code. In FP, all we need to do is define a method that takes a transformation function as argument, and apply it to the collection.

Scala 142
article thumbnail

A Comprehensive Guide to Choosing the Best Scala Course

Rock the JVM

In particular, you will learn: what to look for in a course what’s the best course for beginners if you’re just starting out how you should learn Scala what course to take if you already know the basics of Scala and functional programming how to learn other libraries in the Scala ecosystem The TLDR - which Scala course should I take?

Scala 52
article thumbnail

Functional Error Handling in Kotlin, Part 1: Absent values, Nullables, Options

Rock the JVM

Let’s take the signature of the retrieveSalary method: fun retrieveSalary ( id : JobId ): Double We expect the method to take a job id as input and return a salary as a Double. This article is brought to you by Riccardo Cardin. Kotlin offers a lot of different methods to handle errors. This article is the first part of a series.

article thumbnail

Top 10 Skills (Mostly Mental Models) to Learn to Be a Scala Developer

Rock the JVM

Thankfully, recursion is no rocket science, but it may take some time until it “feels” natural. Skill 2: Another idea is that in Scala - and in functional programming in general - we think code in terms of expressions , i.e. things that are evaluated, instead of instructions , i.e. things that are executed step by step. Apache Spark).

Scala 40