Image for post
Image for post

Introduction

Hey! I have a function:

* you can read about 'def' method in my article at medium

But my teammate write such code:

And code execution output:

Something goes wrong and NullPointerException (NPE) is thrown while main method is executing.

My function and I unexpect that someone pass `null` object as function input value. Hopefully, I have another function that could protect my `cubeVolume` one. Contract is function’s name.

Contract function is function that applied to input value before one is passed to target function. Where target function is…


Image for post
Image for post

Introduction

What is more expressive and shorter Java function definition?

or

In my opinion, the second definition is more expressive and shorter. If you agree with me I recommend to read further.

You can feel free to move to Conclusion part in order to read `def` method implementation.

Problem description

Lambda expression has introduced at Java 8. And It looks like this:

Looks pretty enough, is it? …

Darr Mirr

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store