/* * Copyright (C) 2007-2020 Artima, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Automatically generated Scala interpreter transcript from: * * Programming in Scala (Fifth Edition) * by Martin Odersky, Lex Spoon, Bill Venners, and Frank Sommers * * http://booksites.artima.com/programming_in_scala_5ed */ scala> def maxList[T](elements: List[T]) (using ordering: Ordering[T]): T = elements match case List() => throw new IllegalArgumentException("empty list!") case List(x) => x case x :: rest => val maxRest = maxList(rest)(using ordering) if ordering.gt(x, maxRest) then x else maxRest (using ordering: Ordering[T]): T = ^ On line 2: error: ':' expected but identifier found. if ordering.gt(x, maxRest) then x ^ On line 10: warning: then is a reserved word (since 2.10.0); usage as an identifier is deprecated scala> "hello" == Option("hello") // (in Scala 3) res0: Boolean = false scala> val streetStr: String = street ^ error: not found: value street