Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Chris Sabo
Chris Sabo
3,970 Points

HomeValue reduction wrong types?

Working on the reduction exercise, I see the following for lowest price

public static OptionalInt getLowestHomeValueIndexDeclaratively(List<HousingRecord> records) {

I got that working no issues, however the method for highest isn't "OptionalInt" its "Optional<HousingRecord>". I can fix this, but then the tests are broken.

I'm not sure if I'm doing this wrong or there's an error in the tests/code.

Thomas Salai
Thomas Salai
4,964 Points

Can you post here stacktrace log from the test?

Hi Chris, I'm having the same problem and now my progress is on hold

2 Answers

There's something wrong with the upload and test feature of this course. As long as your code passes the test and can run the prepareSubmission task then you're good. Don't bang your head on it pass that point like I'm sure many of us already have.

I was having the same issue, as I was trying to keep with the provided return statement BUT once I ignored this and mirrored how steams where laid out in the previous lessons, changing it up to match lesson on reduction. it became so much clearer :-)

public static OptionalInt getLowestHomeValueIndexDeclaratively(List<HousingRecord> records) {
    // TODO: Create a stream off the records
        return records.stream()
    // TODO: Map the stream to an IntStream on `HousingRecord.getCurrentHomeValueIndex` to expose new methods
            .mapToInt(HousingRecord::getCurrentHomeValueIndex)
    // TODO: Return the minimum value from the stream.  It should be an optional because records could be empty.
            .min();
  }