Logo

Programming-Idioms

History of Idiom 165 > diff from v40 to v41

Edit summary for version 41 by programming-idioms.org:
[Rust] Better demo

Version 40

2019-09-09, 09:15:25

Version 41

2019-09-09, 09:18:32

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Code
let x = items[items.len()-1];
Code
let x = items[items.len()-1];
Demo URL
https://play.rust-lang.org/?gist=19581826c8e46df13343871138b3a417&version=stable
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=6389b306834e38f679d8d3b926eb603f