Into the Unknown

Photo by Mario Dobelmann on Unsplash

What am I getting into now?

The method into on RichIterable
@Test
public void intoTheUnknown()
{
var integers = Interval.oneTo(10);

var into1 = integers.into(new CopyOnWriteArrayList<>());
Assertions.assertEquals(integers, into1);

var into2 = integers.into(new CopyOnWriteArraySet<>());
Assertions.assertEquals(integers.toSet(), into2);

var into3 = integers.into(new ArrayDeque<>());
Assertions.assertEquals(integers.toBag(),
Bags.mutable.withAll(into3));

var into4 = integers.into(new LinkedList<>());
Assertions.assertEquals(integers, into4);

var into5 = integers.into(new Stack<>());
Assertions.assertEquals(integers, into5);

var checkedList =
Collections.checkedList(new ArrayList<>(), Integer.class);
var into6 = integers.into(checkedList);
Assertions.assertEquals(integers, into6);

var checkedSet =
Collections.checkedSet(new HashSet<>(), Integer.class);
var into7 = integers.into(checkedSet);
Assertions.assertEquals(integers.toSet(), into7);
}
@Test
public void intoList()
{
var target = Interval.oneTo(3).into(new ArrayList<>());
Interval.fromTo(4,6).into(target);
Interval.fromTo(7,10).into(target);
Assertions.assertEquals(Interval.oneTo(10), target);
}

--

--

--

Java Champion. Creator of the Eclipse Collections OSS Java library (http://www.eclipse.org/collections/). Inspired by Smalltalk. Opinions are my own.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

New Website! What’s new in SamanthaMing.com 2.0 🤩

Roland Cloud XV-5080

MY JOURNEY SO FAR IN GIRLSCODING.

Decoupling Workflows in Cloud

Law & Coding: variables vs defined terms

Serious Scrum Weekly Update #58

Serious Scrum weekly digest header

System Architecture Tips

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
Donald Raab

Donald Raab

Java Champion. Creator of the Eclipse Collections OSS Java library (http://www.eclipse.org/collections/). Inspired by Smalltalk. Opinions are my own.

More from Medium

Checklist: When to write custom exceptions in Java

Methods to Inspect and Control Java Threads

SimpleDB: A Basic RDBMS Built From Scratch

CWE-248: Uncaught Exception in Java