Compare commits

...

6 Commits

Author SHA1 Message Date
Éric NICOLAS
9f2356a154
Merge 0ef979f937 into 0b375fe86c 2024-11-27 14:44:43 +08:00
Gustavo Adolfo Mejía Sánchez
0b375fe86c
[hcl/en] fix syntax error (#5187)
All checks were successful
Trigger site build / deploy (push) Has been skipped
CI / lint (push) Successful in 18s
2024-11-23 12:46:21 -07:00
Gustavo Adolfo Mejía Sánchez
c975a23edc
[javascript/es] grammar (#5188)
Update javascript-es.html.markdown
2024-11-23 12:45:19 -07:00
Éric NICOLAS (ccjmne)
0ef979f937
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.
2024-07-04 13:49:47 +02:00
Éric NICOLAS (ccjmne)
d5769cecdd
Fix awkward wording in sample code comments 2024-07-04 13:48:15 +02:00
Éric NICOLAS (ccjmne)
7b5902d723
Remove markdown break in code block 2024-07-04 13:47:34 +02:00
3 changed files with 14 additions and 11 deletions

View File

@ -277,7 +277,7 @@ miFuncion(); // = undefined al mandar a llamar la función
// Las funciones en JavaScript son de primera clase, así que pueden ser asignadas
// a variables y pasadas a otras funciones como argumentos - por ejemplo:
function miFuncion(){
// este código será llamado cada cinco segundos
// este código será llamado después de cinco segundos
}
setTimeout(miFuncion, 5000);
// Note: setTimeout no es parte de JS, pero lo puedes obtener de los browsers
@ -286,7 +286,7 @@ setTimeout(miFuncion, 5000);
// Es posible declarar funciones sin nombre - se llaman funciones anónimas
// y se definen como argumentos de otras funciones.
setTimeout(function(){
// este código se ejecuta cada cinco segundos
// este código se ejecuta después de cinco segundos
}, 5000);
// JavaScript tiene ámbitos de funciones; las funciones tienen su propio ámbito pero

View File

@ -281,9 +281,9 @@ locals {
map = {for x in local.list : x => upper(x) } // "one":"ONE", "two":"TWO", "three":"THREE"
filtered_list = [for k, v in local.map : substr(v, 0, 2) if k != "two" } // "ON", "TH"
filtered_list = [for k, v in local.map : substr(v, 0, 2) if k != "two" ] // "ON", "TH"
prefixed_list = [for v in local.filtered_list : "pre-${k}" } // "pre-ON", "pre-TH"
prefixed_list = [for v in local.filtered_list : "pre-${v}" ] // "pre-ON", "pre-TH"
joined_list = join(local.upper_list,local. filtered_list) // "ONE", "TWO", "THREE", "pre-ON", "pre-TH"

View File

@ -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.
@ -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 = {}
@ -369,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.