- 1. Crystal
- 2. Introduction
- 2.1. Crystal Language
- 2.2. Crystal Shards (3rd party libraries)
- 2.3. How to install 3rd party shards?
- 2.4. Install Crystal
- 2.5. Crystal in Docker on Linux
- 2.6. Hello World (puts)
- 2.7. Run Crystal source code
- 2.8. Compile Crystal to executable
- 2.9. Speed of Crystal
- 2.10. Hello World (print)
- 2.11. Hello Name (variables)
- 2.12. Hello Name with interpolation
- 2.13. Interpolation
- 2.14. Escaping - Alternative quote as delimiters
- 2.15. Debugging print p!
- 2.16. Comments
- 2.17. Code formatting
- 2.18. Types - typeof
- 2.19. Compound Types - typeof
- 2.20. Add numbers - concatenate strings
- 2.21. Add mixed strings and Integers
- 2.22. Numeric Operators
- 2.23. Methods of Int32
- 2.24. Methods of Float64
- 2.25. Program name
- 2.26. Command line arguments - ARGV
- 2.27. Early exit
- 2.28. Rectangle
- 2.29. True values
- 2.30. Math - PI
- 2.31. Read from STDIN
- 2.32. Read number from STDIN
- 2.33. Interactive environments
- 2.34. Crystal one-liners
- 2.35. Crystal and random numbers
- 2.36. Exercise: Hello World
- 2.37. Exercise: Hello Name - STDIN
- 2.38. Exercise: Hello Name - ARGV
- 2.39. Exercise: Circle STDIN
- 2.40. Exercise: Circle ARGV
- 2.41. Exercise: Calculator STDIN
- 2.42. Exercise: Calculator ARGV
- 2.43. Exercise: Age limit
- 3. Strings
- 3.1. Strings intro
- 3.2. Length or size of a string
- 3.3. Locate substring (index, rindex)
- 3.4. Reverse a string
- 3.5. Substring, range of characters
- 3.6. String includes another string
- 3.7. String starts with
- 3.8. String ends with
- 3.9. Replace part of a string (substitute)
- 3.10. Is the string empty or blank?
- 3.11. Iterate over characters of a string
- 3.12. Type conversion from string to float, to int
- 3.13. Converting string to integer or float
- 3.14. Split String
- 3.15. String Transliteration
- 3.16. String Builder
- 3.17. sprintf and %
- 3.18. Split to the same string length
- 3.19. Split characters
- 3.20. printf
- 3.21. Here documents
- 4. Conditionals
- 4.1. Comparison Operators
- 4.2. Spaceship operator
- 4.3. if statement
- 4.4. elsif
- 4.5. unless statement
- 4.6. Suffix if
- 4.7. Suffix unless
- 4.8. Logical operators
- 4.9. Truth-table
- 4.10. case / when
- 4.11. case of types
- 4.12. Ternary operator and or to set default value
- 4.13. Exercise: Number Guessing game - level 0
- 4.14. Solution: Number Guessing game - level 0
- 5. Loops
- 5.1. loop
- 5.2. loop controls (next, break)
- 5.3. while
- 5.4. until
- 5.5. Exercise: Number guessing game
- 5.6. Solution: Number guessing game
- 6. Arrays
- 6.1. Arrays intro
- 6.2. Array elements - indexing
- 6.3. Array iterate over (each, each_with_index)
- 6.4. Array push, append, <<
- 6.5. Empty array
- 6.6. Count digits
- 6.7. Operations on arrays
- 6.8. Add arrays
- 6.9. Repeat arrays
- 6.10. Select (filter, grep)
- 6.11. Reject (negative filter, grep)
- 6.12. Transform with map
- 6.13. Sample from array
- 6.14. Shuffle array
- 6.15. join
- 6.16. Remove nil elements
- 6.17. Create Array with nil
- 6.18. Does array include a value
- 6.19. Delete element from array by value
- 6.20. Delete element from array by location
- 6.21. Insert element into array at location
- 6.22. Arrays shift - remove first element
- 6.23. Arrays uniq elements
- 6.24. First element of the array
- 6.25. Permutations
- 7. Hash
- 7.1. Hash intro
- 7.2. Count words
- 7.3. Create empty hash
- 7.4. Hash and types
- 7.5. Hash get value, get default value
- 7.6. Merge hashes
- 7.7. Delete - remove an element from a hash
- 7.8. Reject - remove an element from a hash
- 7.9. Clear - empty a hash
- 7.10. Select - keep certain key-value pairs
- 7.11. Multi-dimensional hash
- 7.12. Dig a hash
- 8. Files
- 8.1. Files intro
- 8.2. Read from file (slurp)
- 8.3. Read lines into array
- 8.4. Read file line-by-line
- 8.5. Write to file
- 8.6. Append to file
- 8.7. Does file exist?
- 8.8. Size of file?
- 8.9. Last Modified date of file?
- 8.10. Counter
- 8.11. Multi Counter JSON
- 8.12. Multi Counter YAML
- 9. Directories
- 9.1. List directory content
- 9.2. List directory tree
- 9.3. Get Current working directory (cwd, pwd)
- 9.4. Temporary directory
- 9.5. Tempdir function
- 9.6. Join / concatenate file system path
- 9.7. Join / concatenate file system path
- 9.8. Path from string
- 9.9. Expand Path
- 10. Sets
- 10.1. Create empty set
- 10.2. Set examples
- 11. Functions
- 11.1. Functions and methods
- 11.2. Function return value
- 11.3. Function parameter passing
- 11.4. Function parameter default value
- 11.5. Wrong number of arguments
- 11.6. Any number of arguments (splat, *)
- 11.7. Manually separate
- 11.8. Tuple from
- 11.9. Array overload
- 11.10. Multiple dispatch
- 11.11. Implicit return value
- 11.12. Return Type definition
- 11.13. Type or Nil
- 11.14. Yield
- 11.15. Yield with parameters
- 11.16. Block and parameters
- 12. Tuples and Named Tuples
- 12.1. Create Tuple
- 12.2. Create Named Tuple
- 12.3. Access fields of Named Tuple
- 12.4. Named Tuple with non-alphanumeric fields
- 12.5. Named Tuple with optional field
- 13. Structs
- 13.1. Empty struct
- 13.2. Initialize immutable struct
- 13.3. Initialize immutable struct - shorthand
- 13.4. Immutable struct with getters
- 13.5. Immutable struct with getter macro
- 13.6. Mutable Struct with setter
- 13.7. Mutable Struct with property macro
- 13.8. Struct with optional attributes
- 13.9. Struct with default value
- 13.10. Struct pass-by-value
- 13.11. Struct from JSON
- 13.12. Struct from JSON - upper case
- 13.13. Struct both from JSON and initialize
- 13.14. Struct from JSON - manual parsing
- 13.15. Multi-level struct manually
- 13.16. Multi-level struct from JSON
- 13.17. Struct from JSON with extra data
- 13.18. Struct from JSON missing data (optional fields)
- 13.19. Extend struct
- 13.20. Extend other structs
- 14. Classes
- 14.1. Empty Class definition
- 14.2. Class with attributes
- 14.3. Class with getters
- 14.4. Class with setter
- 14.5. Class with getters and setter (property)
- 14.6. Class with property with default value
- 14.7. Class with declared getter and default value
- 14.8. Class with declared getter
- 14.9. Serialize Crystal-lang class to/from JSON from_json to_json
- 14.10. Compare objects for equality
- 14.11. Singleton using class properties
- 14.12. Singleton using class properties with default values
- 14.13. Class monkey-path add method
- 14.14. Stringification to_s
- 15. Regexes
- 15.1. Alternate delimiter matching slashes
- 15.2. Substitute
- 15.3. gsub
- 16. Testing
- 16.1. Testing 1
- 16.2. Testing with Spec
- 17. Modules
- 17.1. Namespace
- 17.2. Extend class - include module
- 18. JSON
- 18.1. JSON (to_json, parse)
- 18.2. JSON to NamedTuple
- 18.3. Reading a JSON file
- 18.4. JSON to Array
- 19. Range
- 19.1. Range using dots
- 19.2. Range using a class
- 19.3. Range - sum
- 19.4. Range - count
- 19.5. Range and loop controls
- 19.6. Range with step
- 19.7. Range to Array
- 20. Random
- 20.1. rand
- 20.2. Random in other parts of Crystal
- 20.3. Random as a class
- 20.4. Random - seed
- 21. YAML
- 21.1. Parse YAML
- 22. Exception Handling in Crystal-lang
- 22.1. Catch exception - begin, rescue
- 22.2. Raise exception
- 23. Logging
- 23.1. Crystal logging
- 24. SQLite
- 24.1. Try SQLite
- 24.2. Multi-counter with SQLite
- 24.3. SQLite last_id last_insert_id
- 24.4. SQLite UPDATE row_affected
- 24.5. SQLite exception handling (during INSERT)
- 24.6. SQLite all
- 24.7. SQLite in memory
- 25. Time
- 25.1. Dates and Time
- 25.2. Sleep
- 25.3. Time difference or Time::Span
- 25.4. Elapsed time
- 25.5. Timestamp formatting
- 25.6. Add timespan
- 25.7. Time Types
- 26. CLI
- 26.1. ARGV
- 26.2. Usage statement and exit
- 26.3. Command line Option Parser (argparse, GetOpts)
- 26.4. Pass parameters to OptionParser
- 26.5. Order of parsing
- 27. HTTP Client
- 27.1. HTTP Client example
- 27.2. Parse URL (URI)
- 27.3. HTTP::Request GET
- 27.4. HTTP::Request POST
- 28. Process
- 28.1. Execute external program (system)
- 28.2. Execute external program (backtick)
- 28.3. Execute external program (Process)
- 28.4. Execute external program (capture)
- 28.5. Execute external program (capture)
- 28.6. Abort
- 29. Concurrency
- 29.1. Send and receive
- 29.2. Concurrent HTTP request
- 30. Kemal
- 30.1. About Kemal
- 30.2. Kemal Install
- 30.3. Hello World
- 30.4. Testing Hello World
- 30.5. Kemal Autorestart (autoreload)
- 30.6. Kemal GET parameters
- 30.7. Kemal POST parameters
- 30.8. Kemal Route parameters
- 30.9. Kemal ECR Templates
- 30.10. Kemal with Jinja templates
- 30.11. Kemal Elapsed time
- 30.12. Accept GET, POST, and route parameter in the same POST route
- 30.13. Kemal indicate 404
- 30.14. Kemal Styling 404 pages
- 30.15. Kemal set headers (change content-type)
- 30.16. Kemal redirect
- 30.17. Kemal in Docker
- 31. Other
- 31.1. Sequence
- 31.2. Check if variable is nil?
- 31.3. Single quotes vs double quotes
- 31.4. No type-checking?
- 31.5. Divide by zero is Infinity
- 31.6. Require other files
- 31.7. List Methods
- 31.8. Checking the slides
- 31.9. Crystal mine
- 31.10. Ameba Linter
- 31.11. Gravatar
- 31.12. Try Crystal
- 31.13. STDERR, STDOUT
- 31.14. Return Boolean
- 31.15. Symbols
- 31.16. Docspec
- 31.17. require
- 31.18. Constants
- 31.19. Multiple assignment
- 31.20. Chained assignment
- 31.21. Int methods: Times
- 31.22. Int64 Zero
- 31.23. Question mark: ?
- 31.24. Exclamation mark: !
- 31.25. Ampersand: &
- 31.26. STDIN don't accept nil
- 31.27. Math
- 31.28. Proc
- 31.29. Enums
- 31.30. Type of array elements
- 31.31. Environment variables
- 31.32. Int32 or Nil
- 31.33. Resources
- 32. Crystal from 0 to Web site
- 32.1. Crystal from 0 to Web site
- 32.2. Background
- 32.3. Why?
- 32.4. I can do better
- 32.5. How to learn
- 32.6. When
- 32.7. Shardbox
- 32.8. What did I learn?
- 32.9. Crystal is fun
- 32.10. Shards
- 32.11. Code formatter
- 32.12. Ameba - Linter
- 32.13. Spectator - testing framework
- 32.14. Code coverage
- 32.15. CI - GitHub Actions
- 32.16. The language
- 32.17. What do ? and ! mean?!
- 32.18. Emojis and Unicode characters 💎
- 32.19. Meaning of ?
- 32.20. Meaning of !
- 32.21. Web framework?
- 32.22. Amber Framework
- 32.23. Lucky Framework
- 32.24. Kemal
- 32.25. Crinja
- 32.26. Shardbox
- 32.27. Future
- 32.28. Thank you - QA ?!?!
- 33. Macros
- 33.1. Macro - increment x by 1
- 33.2. Macro - with parameter and placeholder
- 33.3. Macro Swap
- 33.4. Macro - internal variables - Swap fixed
- 33.5. Macros function
- 33.6. Macro to print type and content