Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jun 30, 2021
1 parent 2979428 commit 683d62b
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crystal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

## Ideas for slides

I run
The need to recompile the whole thing before I run it and the fact that compilation is slow makes life of a (web) developer hard.
The Jinja Template system of Johannes that does not need to be compiled makes at least the HTML development much faster.

I run
crystal example.cr
I get
Showing last frame. Use --error-trace for full trace.
Expand Down
13 changes: 13 additions & 0 deletions crystal/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,16 @@
{id: arrays-join}

![](examples/arrays/join.cr)

## Remove nil elements
{id: remove-nil-elements}
{i: compact}

![](examples/arrays/remove_nils.cr)

## Create Array with nil
{id: array-with-nil}
{i: 0_i64}

![](examples/arrays/array_with_nil.cr)

6 changes: 6 additions & 0 deletions crystal/examples/arrays/array_with_nil.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n = 5
nums = (0_i64.as(Int64 | Nil)..n).to_a
puts typeof(nums) # Array(Int64 | Nil)

other = [nil] + (1..n).to_a
puts typeof(other) # Array(Int32 | Nil)
7 changes: 7 additions & 0 deletions crystal/examples/arrays/remove_nils.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
numbers = [nil, 2, 3, nil, nil, 7, nil]
puts numbers
puts numbers.compact
puts numbers

puts numbers.compact!
puts numbers
4 changes: 4 additions & 0 deletions crystal/examples/int64_zero.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
zero = 0_i64

p! zero
p! typeof(zero)
3 changes: 3 additions & 0 deletions crystal/examples/range/to_a.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numbers = (2..7).to_a
p! typeof(numbers)
p! numbers
2 changes: 2 additions & 0 deletions crystal/examples/range/to_a.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
typeof(numbers) # => Array(Int32)
numbers # => [2, 3, 4, 5, 6, 7]
5 changes: 5 additions & 0 deletions crystal/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,8 @@ require "some_name" # Find it somewhere (standard library, src directory
![](examples/case_when_on_type.cr)


## Int64 Zero
{id: int64-zero}

![](examples/int64_zero.cr)

7 changes: 7 additions & 0 deletions crystal/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@
![](examples/range/step.cr)
![](examples/range/step.out)

## Range to Array
{id: range-to-array}
{i: to_a}

![](examples/range/to_a.cr)
![](examples/range/to_a.out)

0 comments on commit 683d62b

Please sign in to comment.