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 { | |
dateToFormattedString, | |
dateToFormattedStringForInterviewTime, | |
toUTC, | |
utcToJstDateText, | |
utcToJstTimeText, | |
} from './date'; | |
describe('toUTC', () => { | |
it('JSTのDateがUTCに変換される', () => { |
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
module Main exposing (main) | |
import Browser | |
import Browser.Events exposing (onAnimationFrame) | |
import Html exposing (Html, button, div, p, text) | |
import Html.Events exposing (onClick) | |
import Task | |
import Time | |
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
case class LastName private (value: String) extends AnyVal | |
object LastName { | |
private[this] val maxLength = 32 | |
def apply(value: String): LastName = { | |
val trimmed = value.trim | |
require(!trimmed.isEmpty && trimmed.length <= maxLength) | |
new LastName(trimmed) | |
} |
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
> type Suit = Spade | Diamond | Club | Heart | |
> type Rank = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | |
> suits = [ Spade, Diamond, Club, Heart ] | |
[Spade,Diamond,Club,Heart] : List Suit | |
> ranks = [ Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King ] | |
[Ace,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Jack,Knight,Queen,King] | |
: List Rank | |
> type Card = Card Suit Rank | Joker | |
> suits |> List.concatMap (\suit -> ranks |> List.map (Card suit) ) |
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
module Main exposing (main) | |
import Browser | |
import Html exposing (Attribute, Html, button, div, input, label, p, text) | |
import Html.Attributes exposing (type_) | |
import Html.Events exposing (on, onClick, targetChecked) | |
import Json.Decode as JD | |
type alias Model = |
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 insertionSort(list: List[Int]): List[Int] = { | |
list match { | |
case Nil => Nil | |
case List(x) => List(x) | |
case x :: xs => { | |
insert(x, insertionSort(xs)) | |
} | |
} |
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.concurrent._ | |
import scala.concurrent.duration.Duration | |
import ExecutionContext.Implicits.global | |
object Main extends App { | |
def foo(x: Int): Future[Int] = | |
Future { | |
println(s"x: $x") | |
Thread.sleep(300) |
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
type A = { v1: number, v2: number }; | |
type X<K1 extends keyof any, K2 extends keyof any> = { | |
[key in K1]: A | { | |
[key in K2]: A | |
}[] | |
} | |
const f = <K1 extends keyof any, K2 extends keyof any>( | |
obj: X<K1, K2> |
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
// カプセル化してるモジュール部分 | |
type LengthError = (length: number) => string; | |
type ValidationWithError = { | |
validations: ValidationErrors[], | |
errorMessage: string | LengthError | |
} | |
const requiredF = ( | |
fieldText: string | |
): ValidationWithError => { |
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
// privateコンストラクタ | |
class Foo private(text: String) { | |
// コンパニオンオブジェクトからは、privateな値(関数)にアクセスできる | |
def foooo: String = text * Foo.constantValue | |
} | |
object Foo { | |
private val constantValue = 2 | |
// コンパニオンオブジェクトからは、privateコンストラクタにアクセスできる |