docs: remove unnecessary and true in example config#73
docs: remove unnecessary and true in example config#73herrscher-of-sleeping wants to merge 1 commit intofolke:mainfrom
and true in example config#73Conversation
|
This PR is stale because it has been open 30 days with no activity. |
There was a problem hiding this comment.
@herrscher-of-sleeping
That and true is a logical expression to give a default value if vim.g.lazydev_enabled is not explicitly set.
In a nutshell, this statement:
return vim.g.lazydev_enabled == nil and true or vim.g.lazydev_enabledis IDENTICAL to the following statement:
if vim.g.lazydev_enabled == nil then -- if variable is nil
return true -- Return default value (`true`)
end
-- Otherwise, return the value (whether `true` or `false`) of `vim.g.lazydev_enabled`
return vim.g.lazydev_enabled Essentially this is just a safeguard to enable the plugin unless explicitly said not to.
The Lua reference is here
|
Maybe I'm missing something here, but still let me explain. There's no difference between
Hence there's no point in adding I also prepared an example script that compares result of all the 3 versions of this calculation for all possible inputs that make sense to be tested:
local function calc0(lazydev_enabled)
if lazydev_enabled == nil then
return true
end
return lazydev_enabled
end
local function calc1(lazydev_enabled)
return lazydev_enabled == nil and true or lazydev_enabled
end
local function calc2(lazydev_enabled)
return lazydev_enabled == nil or lazydev_enabled
end
local input_values = {
nil,
false,
true,
"kutulu",
}
for i = 1, 4 do
local value = input_values[i]
print(("result for %6s is: %6s, %6s, %6s"):format(value, calc0(value), calc1(value), calc2(value)))
endAll the three functions return the same value: |
|
This PR is stale because it has been open 30 days with no activity. |
Description
Just a small cleanup in example config.
and truedoes nothing unless I'm missing something here.Related Issue(s)
None
Screenshots
None