Comparison

doc/coding_style.md @ 9899:8c831c76fc94

doc/coding_style: Trim trailing whitespace
author Kim Alvefur <zash@zash.se>
date Sat, 23 Mar 2019 03:56:55 +0100
parent 9898:34a670e2bcfd
child 9900:f2104b36f673
comparison
equal deleted inserted replaced
9898:34a670e2bcfd 9899:8c831c76fc94
328 that `check_version` is a method of `Api` if it says `function Api:check_version()` 328 that `check_version` is a method of `Api` if it says `function Api:check_version()`
329 than if it says `check_version = function()` under some indentation level. 329 than if it says `check_version = function()` under some indentation level.
330 330
331 ## Variable declaration 331 ## Variable declaration
332 332
333 * Always use `local` to declare variables. 333 * Always use `local` to declare variables.
334 334
335 ```lua 335 ```lua
336 -- bad 336 -- bad
337 superpower = get_superpower() 337 superpower = get_superpower()
338 338
444 -- bad 444 -- bad
445 if test < 1 and do_complicated_function(test) == false or seven == 8 and nine == 10 then do_other_complicated_function() end 445 if test < 1 and do_complicated_function(test) == false or seven == 8 and nine == 10 then do_other_complicated_function() end
446 446
447 -- good 447 -- good
448 if test < 1 and do_complicated_function(test) == false or seven == 8 and nine == 10 then 448 if test < 1 and do_complicated_function(test) == false or seven == 8 and nine == 10 then
449 do_other_complicated_function() 449 do_other_complicated_function()
450 return false 450 return false
451 end 451 end
452 ``` 452 ```
453 453
454 * Separate statements onto multiple lines. Do not use semicolons as statement terminators. 454 * Separate statements onto multiple lines. Do not use semicolons as statement terminators.
455 455
464 b = 2 464 b = 2
465 ``` 465 ```
466 466
467 ## Spacing 467 ## Spacing
468 468
469 * Use a space after `--`. 469 * Use a space after `--`.
470 470
471 ```lua 471 ```lua
472 --bad 472 --bad
473 -- good 473 -- good
474 ``` 474 ```