This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Access last element of a vector

Tags: None
(comma "," separated)
arennuit
Registered Member
Posts
28
Karma
0

Access last element of a vector

Wed Mar 02, 2016 2:41 pm
Hello,

Is there nothing simpler than

Code: Select all
Vector<float, Dynamic> myVec(7);
myVec.tail(1)(0);


to access the last element of a vector?

Thanks,

Antoine.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Access last element of a vector

Wed Mar 02, 2016 4:08 pm
myVec.reverse()(0) or myVec(n-1);
arennuit
Registered Member
Posts
28
Karma
0

Re: Access last element of a vector

Wed Mar 02, 2016 6:45 pm
All good, thanks!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft