Logo

Programming-Idioms

History of Idiom 165 > diff from v21 to v22

Edit summary for version 22 by Rustem B.:
New Rust implementation by user [Rustem B.]

Version 21

2018-04-03, 08:45:23

Version 22

2018-04-18, 11:20:15

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]
Demo URL
https://play.rust-lang.org/?gist=19581826c8e46df13343871138b3a417&version=stable