This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tv.codely.scala_intro_examples.lesson_09_oop | |
final class StandardClass( | |
val attributeInConstruct: String, | |
private val privateAttributeInConstruct: String = "Some default value" | |
) { | |
val attributeInBody = "public body attribute value" | |
private val privateAttributeInBody = "private body attribute value" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// 馃憤 Videos folder in grid view (with video duration) | |
const videosInGridView = Array.from(document.querySelectorAll(".sc-jWBwVP")).reverse(); | |
const videoSummaries = videosInGridView.map(function (video) { | |
const videoLink = video.querySelector("h4 > a"); | |
const videoTitle = videoLink.getAttribute("title"); | |
const videoUrl = 'https://vimeo.com' + videoLink.getAttribute("href").replace('/settings', ''); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tv.codely.cqrs_ddd_scala_example.acceptance | |
import java.util.UUID | |
import scala.reflect.classTag | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import cats.implicits._ | |
import org.joda.time.DateTime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum(a: Int)(b: Int): Int = a+ b | |
def add1(b:Int) = sum(1)(b) | |
def add2(b:Int) = sum(2)(b) | |
def add3(b:Int) = sum(3)(b) | |
val add4 = sum(4)(_) | |
add2(5) | |
add4(6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print( | |
value: String, | |
printer: String => Unit | |
): Unit = printer(value) | |
def printlnPrinter(value: String): Unit = println(value) | |
val printlnPrinterVal = (value: String) => println(value) | |
print("Playing with higher order functions", printlnPrinter) | |
print("Same with functions stored in values", printlnPrinterVal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tv.codely.scala_intro_examples.lesson_05_ifs_for | |
import scala.concurrent.{ExecutionContext, Future} | |
final class SandwichMaker(private val fridge: Fridge, private val fryer: Fryer)(implicit ec: ExecutionContext) { | |
def make(): Future[Sandwich] = { | |
val breadOptionFuture = fridge.takeBread() | |
val cheeseOptionFuture = fridge.takeCheese() | |
val hamOptionFuture = fridge.takeHam() | |
val eggOptionFuture = fridge.takeEgg() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val lele = if ("Codely mola".isInstanceOf[String]) 3 else 7 | |
var total = 0 | |
for (value <- 1 to 10) { | |
total = total + value | |
println(value) | |
} | |
(1 to 10).foreach(value2 => { | |
println(value2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val lele = if ("Codely mola".isInstanceOf[String]) 3 else 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.Random | |
var javi = "Javi" * 10 // Inferencia de tipos | |
javi = "Rafa" // podemos reasignar el contenido de una variable (var) | |
val rafa = "Rafa" // ";" al final de l铆nea no necesario | |
// rafa = "Javi" // Petar铆a en tiempo de compilaci贸n. No podemos reasignar el contenido de un valor (val) | |
def codely(name: String): String = { // funci贸n p煤blica con tipo de retorno expl铆cito. Se declaran con = ya que asignamos una expresi贸n. | |
println("Este mensaje se imprimir谩 por pantalla al invocar a la funci贸n codely") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Post: http://codely.tv/screencasts/finder-kata-scala/ | |
// Repo: https://github.com/CodelyTV/incomprehensible-finder-refactoring-kata-scala | |
package tv.codely.finderKata.algorithm | |
final class BestPeoplePairFinder() { | |
def find(people: Seq[Person], peoplePairCriterion: Ordering[PeoplePair]): Option[PeoplePair] = { | |
val canFindPeoplePairs = people.size >= 2 | |
if (!canFindPeoplePairs) { |