1# An example file to test Crystal syntax highlighting in bat
3my_var_also : Int32 = 42
8big_one = 1_000_000.111_111e-4
11my_other_symbol = :No_That_One!
14my_string : String = "this string right here, with an interpolated value of #{my_var_also}"
15my_array : Array(Int32) = [1,2,3,4]
16my_tuple : Tuple(Int32, Int32, Int32, Int32) = {1,2,3,4}
17my_named_tuple : NamedTuple(one: Int32, two: Int32) = {"one": 1, "two": 2}
18my_hash : Hash(String, Int32) = {"one" => 1, "two" => 2}
19my_proc : Proc(Int32, Int32) = ->(x : Int32){ x * x}
20my_other_proc : Proc(String) = ->{ "Wow, neat!" }
31 @instance_field = Colors::Red
32 @@class_field = Colors::Green
34 def initialize(@name = "world")
38 puts "Hello, #{@name}"
41 def render_greeting : String
50 @instance_field == @@class_field
53 def self.greet_static(name : String) : Unit
58greeter = Greeter.new("bat")
59greeter.with_greeting do |greeting|
64 this is a heredoc and it has a value in it of #{greeter.render_greeting}!
75 when Colors::Red, .red?
77 when Colors::Green, .green?
79 when Colors::Blue, .blue?
82 "I dunno, man. Chartreuse? Maroon?"
85class MyGenericClass(T)
86 def initialize(@wrapped_value : T)
95def do_stuff_with_range(r : Range(Int|String))
97 return unless !(r.empty?)
99 if /e/.match(item.to_s)
100 puts "#{item} contains the letter e!"
101 elsif item.to_s.empty?
104 next # this is unnecessary, but whatever
110macro print_range(range)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list