empty string should return empty object instead of undefined
See original GitHub issueIs there any good reason why yaml.safeLoad("")
returns undefined
instead of {}
?
It looks to me that emtpy string should match empty object. Also, an empty file say file.yml
may be empty and loading it should return the emtpy object also.
Looks to me that undefined may refer to more than one semantics and may be ambiguos, say an error or whatever the safeLoad()
method does inside that honestly I don’t care what it does in detail, but I care the “contract” of its use.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Should functions return null or an empty object? - Stack Overflow
An empty object implies data has been returned, whereas returning null clearly indicates that nothing has been returned. Additionally, returning ...
Read more >3 Clever Ways to Return Empty Value Instead of Null From a ...
It is best practice to return empty values rather than null ones. Especially when you return a collection, enumerable, or an object, you...
Read more >Is it better to return NULL or empty values from functions ...
An empty object implies data has been returned, whereas returning null clearly indicates that nothing has been returned. Additionally, returning ...
Read more >Return Optional not null - Java Practices
you can usually simply return an empty object instead of null , and it will work fine, without special handling. In these cases,...
Read more >String.IsNullOrEmpty(String) Method (System) - Microsoft Learn
You can use the IsNullOrWhiteSpace method to test whether a string is null , its value is String.Empty, or it consists only of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@puzrin sorry, my explanation was incorrect! I edited it. Hope it’s clearer now.
@perlpunk thank you! created #567