[Interest] documentation for QString::right(int n) confuse

Scott Aron Bloom scott.bloom at onshorecs.com
Tue Jun 4 06:13:56 CEST 2013


I think saying "the n rightmost characters" is pretty clear...

If it was from the index (which makes no sense for a "right" function) it would be 0 index'ed based, and would return the right characgters starting from the 5th 0 based position which would be the 6th character, and be pple

Scott

From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Duan,Lin
Sent: Monday, June 3, 2013 8:38 PM
To: interest at qt-project.org
Subject: [Interest] documentation for QString::right(int n) confuse

here it says:
------------------------------------------------------------------------------------------------
QString QString::right(int n) const

Returns a substring that contains the n rightmost characters of the string.

The entire string is returned if n is greater than size<http://qt-project.org/doc/qt-5.0/qtcore/qstring.html#size>() or less than zero.

QString<http://qt-project.org/doc/qt-5.0/qtcore/qstring.html> x = "Pineapple";

QString<http://qt-project.org/doc/qt-5.0/qtcore/qstring.html> y = x.right(5);      // y == "apple"

------------------------------------------------------------------------------------------------
I make a mistake for that today.

because there was the same for result string "apple",
either from left to right counting 5, or from right to left counting 5.
Only watched the example, but not read the illustration above.
I deem the 5 is the index for the string.

the example for doc should be better?:

QString<http://qt-project.org/doc/qt-5.0/qtcore/qstring.html> x = "ThereHaveOneApple";

QString<http://qt-project.org/doc/qt-5.0/qtcore/qstring.html> y = x.right(5);      // y == "Apple"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130604/7e4f4bdd/attachment.html>


More information about the Interest mailing list