Urara-Blog/node_modules/.pnpm-store/v3/files/11/b58b38dcbbd24572b6d5b88cfa8e9993764145299000b2ab34925866bf32ca6775fe4d6d3a2c2d9f945738cc0b201616e9fee46bce3ee45d8ee0c8b3f58249
2022-08-14 01:14:53 +08:00

43 lines
No EOL
572 B
Text

struct Foo(T)
end
Foo(Int32)
# ---
struct Foo
end
# struct Bar < Foo
# end
# Error in ./struct/struct.cr:10: can't extend non-abstract struct Foo
abstract struct AbstractFoo
end
struct Bar < AbstractFoo
end
# ---
struct Test
def initialize(@test : String)
end
end
Test.new("foo")
# ---
struct User
property name, age
def initialize(@name : String, @age : Int32)
end
def print
puts "#{age} - #{name}"
end
end
puts User.new("osman", 3).name
User.new("ali", 9).print
# From https://github.com/askn/crystal-by-example/blob/master/struct/struct.cr