Skip to content

Commit

Permalink
string.empty?
Browse files Browse the repository at this point in the history
Summary: Basic string operation

Differential Revision: D68424373

fbshipit-source-id: aabce9baae8aa5559aa5cc5106430dfaa56d005c
  • Loading branch information
praihan authored and facebook-github-bot committed Jan 25, 2025
1 parent c8d6cf9 commit 695d212
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions thrift/compiler/whisker/standard_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ map::value_type create_string_functions() {
return i64(ctx.argument<string>(0)->length());
});

/**
* Checks a string for emptiness.
*
* Name: string.empty?
*
* Arguments:
* - [string] — The string to check for emptiness.
*
* Returns:
* [boolean] indicating whether the string is empty.
*/
string_functions["empty?"] = dsl::make_function(
"string.empty?", [](dsl::function::context ctx) -> boolean {
ctx.declare_named_arguments({});
ctx.declare_arity(1);
return ctx.argument<string>(0)->empty();
});

/**
* Produces the provided string concatenated together.
*
Expand Down

0 comments on commit 695d212

Please sign in to comment.