Skip to content

Commit

Permalink
feat(array): indexing with .first and .last
Browse files Browse the repository at this point in the history
  • Loading branch information
Goncalerta committed Oct 21, 2018
1 parent 5f213e1 commit 36d79cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion liquid-value/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ impl Value {
};
x.get(index as usize)
} else {
None
match &*index.to_str() {
"first" => x.get(0),
"last" => x.get(x.len() - 1),
_ => None,
}
}
}
Value::Object(ref x) => x.get(index.to_str().as_ref()),
Expand Down

0 comments on commit 36d79cf

Please sign in to comment.