Ad
Fundamentals
Arrays
Strings
Code
Diff
  • object FindTRex:
      val containsTRex = (_:Array[String]).contains("Tyrannosaurus")
    
    • object FindTRex:
    • val containsTRex: Array[String] => Boolean = _.contains("Tyrannosaurus")
    • val containsTRex = (_:Array[String]).contains("Tyrannosaurus")
Fundamentals
Arrays
Strings
Code
Diff
  • object FindTRex:
      val containsTRex: Array[String] => Boolean = _.contains("Tyrannosaurus")
    
    • object FindTRex:
    • def containsTRex(things: Array[String]): Boolean = things.contains("Tyrannosaurus")
    • val containsTRex: Array[String] => Boolean = _.contains("Tyrannosaurus")
Code
Diff
  • object FindMultiples:
      def findMultiples: Int => Int = n =>
        (0 until n by 2).filter(i => (i%4)*(i%6) == 0).sum
    
    • object FindMultiples:
    • def findMultiples(n: Int): Int =
    • Seq.range(0, n).filter(i => i % 4 == 0 || i % 6 == 0).sum
    • def findMultiples: Int => Int = n =>
    • (0 until n by 2).filter(i => (i%4)*(i%6) == 0).sum