remove duplicated code

This commit is contained in:
Ophir LOJKINE 2022-03-14 16:08:08 +01:00
parent af77f1703e
commit 65bf8adc9c

View File

@ -123,11 +123,8 @@ pub fn builtin_function(identifier: &str) -> Option<Function> {
})),
"if" => Some(Function::new(|argument| {
let mut arguments = argument.as_fixed_len_tuple(3)?;
Ok(if arguments[0].as_boolean()? {
arguments.swap_remove(1)
} else {
arguments.swap_remove(2)
})
let result_index = if arguments[0].as_boolean()? { 1 } else { 2 };
Ok(arguments.swap_remove(result_index))
})),
"len" => Some(Function::new(|argument| {
if let Ok(subject) = argument.as_string() {