Add sections
This commit is contained in:
parent
b32329935c
commit
733921a2ff
@ -103,8 +103,8 @@ import HeroSection from "../components/HeroSection.astro";
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<HeroSection
|
<HeroSection
|
||||||
subtitle="THP is"
|
subtitle="We've got"
|
||||||
title="typed"
|
title="generics"
|
||||||
thpcode={`
|
thpcode={`
|
||||||
Array[Int] numbers = [0, 1, 2, 3, 4, 5]
|
Array[Int] numbers = [0, 1, 2, 3, 4, 5]
|
||||||
|
|
||||||
@ -136,16 +136,58 @@ import HeroSection from "../components/HeroSection.astro";
|
|||||||
</HeroSection>
|
</HeroSection>
|
||||||
|
|
||||||
<HeroSection
|
<HeroSection
|
||||||
subtitle="THP is"
|
subtitle="We've got"
|
||||||
title="match"
|
title="tagged unions"
|
||||||
thpcode={`
|
thpcode={`
|
||||||
match value
|
union DirEntry {
|
||||||
case A
|
File(String),
|
||||||
|
Dir(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
val root = DirEntry::Dir("/")
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
Make invalid state irrepresentable.
|
||||||
|
<br>
|
||||||
|
Model data in a type-safe way.
|
||||||
|
<br>
|
||||||
|
Ensure all cases are handled.
|
||||||
|
</HeroSection>
|
||||||
|
|
||||||
|
<HeroSection
|
||||||
|
subtitle="We've got"
|
||||||
|
title="pattern matching"
|
||||||
|
thpcode={`
|
||||||
|
match test_file
|
||||||
|
case DirEntry::File(filename)
|
||||||
|
if !filename.starts_with(".")
|
||||||
{
|
{
|
||||||
|
print(filename)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print("A valid file was not found")
|
||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
:D (carita feliz)
|
Match on values, tuples, enums, unions, types etc.
|
||||||
|
<br>
|
||||||
|
Guards available!
|
||||||
|
</HeroSection>
|
||||||
|
|
||||||
|
<HeroSection
|
||||||
|
subtitle="We've got"
|
||||||
|
title="null safety"
|
||||||
|
thpcode={`
|
||||||
|
String? username = Globals::Post::get("username")
|
||||||
|
|
||||||
|
if username? {
|
||||||
|
// username is a \`String\` here
|
||||||
|
print("Hello, {username}")
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
Nulls are explicit and require handling.
|
||||||
</HeroSection>
|
</HeroSection>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
Reference in New Issue
Block a user