O'Reilly logo

Get Programming with F#: A guide for .NET developers by Isaac Abraham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 9. Shaping data with tuples

You’ll start this unit by looking at the simplest data structure in F#, the tuple. Tuples are a great way to quickly pass small bits of data around your code when classes or similar elements feel like overkill. In this lesson

  • You’ll see how tuples are used within F#.
  • You’ll understand when to use and not use them.
  • You’ll see how tuples work together with type inference to enable succinct code.
  • You’ll see how tuples relate to the rest of .NET.

9.1. The need for tuples

Let’s start by considering an example that seems trivial and yet gets us in all sorts of contortions nearly every day. The following method takes in a string that contains an individual’s name (for example, "Isaac Abraham") and splits it into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required