Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jun 25, 2021
1 parent c14a413 commit a6b6ef9
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crystal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ filter or grep => reject (use the names other languages use for the same conce

What is "flag?" ? I saw it in the source code of Kemal, but I don't see it defined anywhere.

GitHub Actions configurators: https://crystal-lang.github.io/install-crystal/configurator.html

Yak Shaving

https://forum.crystal-lang.org/ has around 500 users.
https://gitter.im/crystal-lang/crystal Gitter 1960 people


### SQLite

Lack of documentation
last_id last_insert_id How can one know?

puts __FILE__



3 changes: 3 additions & 0 deletions crystal/examples/assign.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a = b = 42
puts a # 42
puts b # 42
4 changes: 4 additions & 0 deletions crystal/examples/constants.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PI = 3.14

puts PI
PI = 3.145 # Error: already initialized constant PI
8 changes: 8 additions & 0 deletions crystal/examples/multiple_assignments.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a, b = 2, 3
puts a # 2
puts b # 3


a, b = b, a
puts a # 3
puts b # 2
36 changes: 36 additions & 0 deletions crystal/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,39 @@ shards install

![](examples/docspec/src/app.cr)

## require
{id: require}

{aside}
require - imports are global. This makes it hard to see in a file where some objects might come from
as they might have been required by some other file.

Similarly requiring a bunch of files in a directory is easy to do, but might make it a bit harder for
someone without an IDE to find the source of each object.
{/aside}

```
require "./directory/file" # relative path to the cr file
require "./directory/*" # all the cr files in the directory
require "./directory/**" # all the cr files in the directory - recursively
require "some_name" # Find it somewhere (standard library, src directory)
```

* You can put the `require` statements anywhere but you might want to be consistent in your porject.
* Make sure you don't have circular requires.

## Constants
{id: constants}

* Variable names that start with upper-case letter are constants

![](examples/constants.cr)

## Multiple assignments
{id: multiple-assignments}

![](examples/multiple_assignments.cr)

![](examples/assign.cr)


18 changes: 18 additions & 0 deletions crystal/spec/todo_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def add(x, y)
return x*y
end


describe "test cases" do
it "good" do
add(2, 2).should eq 4
end

pending "another test case when the bug is fixed"
it "add" do
add(2, 3).should eq 5
end
it "add" do
add(2, 4).should eq 6
end
end
2 changes: 2 additions & 0 deletions crystal/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ crystal spec .

![](spec/demo_spec.cr)

![](spec/todo_spec.cr)

```
crystal spec
```
Expand Down

0 comments on commit a6b6ef9

Please sign in to comment.