From 7b5902d72366878c50327edf6d5f5a4d4f6c4c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20NICOLAS=20=28ccjmne=29?= Date: Thu, 4 Jul 2024 13:47:34 +0200 Subject: [PATCH 1/3] Remove markdown break in code block --- lua.html.markdown | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua.html.markdown b/lua.html.markdown index a755e6e1..a56e4372 100644 --- a/lua.html.markdown +++ b/lua.html.markdown @@ -332,9 +332,6 @@ end --[[ I'm commenting out this section so the rest of -- this script remains runnable. -``` - -```lua -- Suppose the file mod.lua looks like this: local M = {} From d5769cecddba1355d965f9840d48c8c6068f2d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20NICOLAS=20=28ccjmne=29?= Date: Thu, 4 Jul 2024 13:48:15 +0200 Subject: [PATCH 2/3] Fix awkward wording in sample code comments --- lua.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua.html.markdown b/lua.html.markdown index a56e4372..01ab29b7 100644 --- a/lua.html.markdown +++ b/lua.html.markdown @@ -232,8 +232,8 @@ eatenBy = myFavs.animal -- works! thanks, metatable -- An __index value can also be a function(tbl, key) -- for more customized lookups. --- Values of __index,add, .. are called metamethods. --- Full list. Here a is a table with the metamethod. +-- The values of __index, __add, etc are called +-- metamethods. Here's their full list: -- __add(a, b) for a + b -- __sub(a, b) for a - b @@ -258,7 +258,7 @@ eatenBy = myFavs.animal -- works! thanks, metatable -- Classes aren't built in; there are different ways -- to make them using tables and metatables. --- Explanation for this example is below it. +-- The explanation for this example follows it. Dog = {} -- 1. From 0ef979f9372fbbd56dea00cbbad1653284f27bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20NICOLAS=20=28ccjmne=29?= Date: Thu, 4 Jul 2024 13:49:47 +0200 Subject: [PATCH 3/3] Fix sample code At a later point, this guide assumes that the return value of mod2.lua is a function. This commit sets that up so it all makes sense. --- lua.html.markdown | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua.html.markdown b/lua.html.markdown index 01ab29b7..aad207fc 100644 --- a/lua.html.markdown +++ b/lua.html.markdown @@ -366,7 +366,13 @@ mod.sayMyName() -- error -- require's return values are cached so a file is -- run at most once, even when require'd many times. --- Suppose mod2.lua contains "print('Hi!')". +-- Suppose another file, mod2.lua, containing this: +print('Hi!') +return function () + return 'foo' +end + +-- local a = require('mod2') -- Prints Hi! local b = require('mod2') -- Doesn't print; a=b.