Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· OpenAIAi2 WildChat-4.8M (AI2)

rewrite this so there is no casting to Number return batches.stream()…

  1. User

    rewrite this so there is no casting to Number return batches.stream() .max(Comparator.comparingInt(batch -> batch.stream() .filter(item -> item instanceof Number) .mapToInt(item -> ((Number) item).intValue()) .sum())) .orElse(Collections.emptyList());

  2. Assistant

    return batches.stream() .max(Comparator.comparingInt(batch -> batch.stream() .filter(Number.class::isInstance) .mapToInt(item -> item.intValue()) .sum())) .orElse(Collections.emptyList());