Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jun 8, 2021
1 parent e905720 commit 8290af0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
1 change: 0 additions & 1 deletion crystal/examples/arrays/filter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ puts small

big = numbers.reject! do |num| num < 10 end
puts big

2 changes: 1 addition & 1 deletion crystal/examples/classes/class_with_property.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Person
property name : String
property name : String

def initialize(@name = "George")
end
Expand Down
8 changes: 4 additions & 4 deletions crystal/examples/functions/default_value.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def welcome(name = "World")
return "Hello #{name}!"
end
puts welcome
puts welcome("Foo")
end

puts welcome
puts welcome("Foo")
6 changes: 3 additions & 3 deletions crystal/examples/functions/parameter_passing.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def welcome(name)
return "Hello #{name}!"
end
puts welcome("Foo")
end

puts welcome("Foo")
11 changes: 11 additions & 0 deletions crystal/examples/json_to_named_tuple.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "json"


alias Thing = NamedTuple(name: String, number: Int32)

thing_json = %{{"name": "table", "number": 3}}
puts thing_json

tg = Thing.from_json(thing_json)
puts tg

4 changes: 4 additions & 0 deletions crystal/examples/try.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# counter = Int32|Nil

# counter = 2
# puts counter + 1


# person = {
Expand Down
6 changes: 6 additions & 0 deletions crystal/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,14 @@ crystal spec

![](examples/gravatar.cr)

## JSON to NamedTuple
{id: json-to-namedtuple}
{i: NamedTuple}
{i: from_json}

## Reading a JSON file
{id: reading-a-json-file}
{i: NamedTuple}

![](examples/math.json)
![](examples/read_math_json.cr)
Expand Down

0 comments on commit 8290af0

Please sign in to comment.