add a tagging system to the website
This commit is contained in:
parent
701da6bc4b
commit
e1b6578b2a
97 changed files with 1025 additions and 979 deletions
|
@ -1,4 +1,6 @@
|
|||
title = "Classes in Lua"
|
||||
id = "b?01JKKQZRSG5ZRNH530D75E2660"
|
||||
tags = ["all", "programming", "lua"]
|
||||
|
||||
+++
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ local Player = Entity:inherit()
|
|||
```lua
|
||||
local Cat = {}
|
||||
-- We still need to override __index, so that the metatable we set in our own constructor
|
||||
-- has our overridden `speak()` method.
|
||||
-- has our overridden `speak()` method.
|
||||
Cat.__index = Cat
|
||||
-- To be able to call `Animal` methods from `Cat`, we set it as its metatable.
|
||||
-- Remember that `Animal.__index == Animal`.
|
||||
|
@ -380,7 +380,7 @@ local Player = Entity:inherit()
|
|||
-- insert below the `end` of `function Class:inherit()`
|
||||
|
||||
-- By default, let's make the base `Class` impossible to instantiate.
|
||||
-- This should catch bugs if a subclass forgets to override `initialize`.
|
||||
-- This should catch bugs if a subclass forgets to override `initialize`.
|
||||
function Class:initialize()
|
||||
error("this class cannot be initialized")
|
||||
end
|
||||
|
@ -462,7 +462,7 @@ local Player = Entity:inherit()
|
|||
|
||||
% id = "01JKKQHG5DQW7G1HDWYGX4WEYC"
|
||||
- our class library implements a Ruby-style `Object:new(args)` function for constructing new instances of our class.
|
||||
Python however, uses the syntax `Object(args)` for constructing instances of objects.
|
||||
Python however, uses the syntax `Object(args)` for constructing instances of objects.
|
||||
can you think of a way to make our class library use the Python-style syntax?
|
||||
|
||||
% id = "01JKKQHG5D7QN029A3F1B6SYC2"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue