/* * 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> List(1, 2, 3) res0: List[Int] = List(1, 2, 3) scala> mutable.Set(1, 2, 3) ^ error: not found: value mutable scala> mutable.Map(1->"hi", 2->"there") ^ error: not found: value mutable scala> Array(1, 2, 3) res3: Array[Int] = Array(1, 2, 3) scala> List(1, 2, 3) res4: List[Int] = List(1, 2, 3) scala> List.apply(1, 2, 3) res5: List[Int] = List(1, 2, 3) scala> val original = Set(1, 2, 3) original: scala.collection.immutable.Set[Int] = Set(1, 2, 3) scala> val updated = original + 5 updated: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 5) scala> original res6: scala.collection.immutable.Set[Int] = Set(1, 2, 3) scala> val people = Set("Nancy", "Jane") people: scala.collection.immutable.Set[String] = Set(Nancy, Jane) scala> people += "Bob" ^ error: value += is not a member of scala.collection.immutable.Set[String] Expression does not convert to assignment because receiver is not assignable. scala> import scala.collection.mutable import scala.collection.mutable scala> val stuff = mutable.Set(42) stuff: scala.collection.mutable.Set[Int] = HashSet(42) scala> stuff += "abracadabra" ^ error: type mismatch; found : String("abracadabra") required: Int scala> val stuff = mutable.Set[Any](42) stuff: scala.collection.mutable.Set[Any] = HashSet(42) scala> import scala.collection.immutable.TreeSet import scala.collection.immutable.TreeSet scala> val treeSet = TreeSet(colors) ^ error: not found: value colors scala> def longestWord(words: Array[String]): (String, Int) = var word = words(0) var idx = 0 for i <- 1 until words.length do if words(i).length > word.length then word = words(i) idx = i (word, idx) var word = words(0) ^ On line 2: error: illegal start of simple expression for i <- 1 until words.length do ^ On line 4: error: '(' expected but identifier found. if words(i).length > word.length then ^ On line 5: warning: then is a reserved word (since 2.10.0); usage as an identifier is deprecated scala> longest(0) ^ error: not found: value longest scala> longest(1) ^ error: not found: value longest scala> val (word, idx) = longest ^ error: not found: value longest scala> word ^ error: not found: value word scala> val word, idx = longest ^ error: not found: value longest