Content deleted Content added
→Protected edit request on 9 April 2024: new section Tag: Reverted |
m Reverted edits by 205.207.203.15 (talk) (HG) (3.4.13) |
||
(17 intermediate revisions by 15 users not shown) | |||
Line 218:
Where lines 15 and 23 are new compared to the current code. <span style="border:1px solid maroon; padding:0 2px">[[User:CRwikiCA|<span style="font-family:'Courier';color:maroon">CRwikiCA</span>]] [[User talk:CRwikiCA|<i style="color:navy">talk</i>]]</span> 18:17, 23 April 2015 (UTC)
:No opposition, so {{done}} — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 10:43, 27 April 2015 (UTC)
::I would be interested to know cases where such "t/f" values may be encountered. I know that in command prompts we may encounter "y/n" choices. But I cannot recall having ever encountered "t/f".
::Refs [[phab:T137584|T137584]] (« Allow Scribunto code to add a category without changing output »), which would allow to know on what (and how many) pages these values are actually used.
::[[User:Od1n|Od1n]] ([[User talk:Od1n|talk]]) 00:05, 20 October 2024 (UTC)
== Support on/off detection ==
Line 249 ⟶ 252:
::This can also mostly be handled by specifying the default parameter (i.e. <syntaxhighlight lang="lua" inline>myvariable = yesno(value, false)</syntaxhighlight>), although this does leave the case <syntaxhighlight lang="lua" inline>yesno(nil, false)</syntaxhighlight>, which evaluates to <syntaxhighlight lang="lua" inline>nil</syntaxhighlight>. The reason I originally programmed the module this way is so that it can be mostly backwards-compatible with [[Template:Yesno]], which it is intended to replace. Originally the plan was to do a straight conversion of [[Template:Yesno]] to Lua, but it turned out that doing that was actually slower than just using the template, given the template's simplicity and the initial cost of switching between PHP and Lua. So instead this module became Lua-only, with most of the behaviour of [[Template:Yesno]]. The intention there was that module writers could easily incorporate it into modules that convert more complex templates without having to change the template logic too much. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 22:11, 23 December 2021 (UTC)
:::OK, thx. I can use this code solution with confidence now, no research-&-test needed. Might as well add it to the /doc. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 16:35, 24 December 2021 (UTC)
::::The abovementioned <code>yesno(value) or true/false</code> has a common pitfall and should be avoided: if value is "false", <code>yesno(value) or true</code> would gives "true", instead of the presumably expected "false". See section « Standard solution: and/or » on [http://lua-users.org/wiki/TernaryOperator this page]. [[User:Od1n|Od1n]] ([[User talk:Od1n|talk]]) 18:15, 22 September 2024 (UTC)
|