# How to use index RTL type

**URL:** https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057
**Category:** Elements
**Created:** [August 7, 2022, 1:32pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057 "2022-08-07T13:32:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [August 7, 2022, 1:32pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/1 "2022-08-07T13:32:30Z")

</div>

Hello,

I want to use the range index, and let the following codes complie fine when targeting JAVA:

var array = new int[] { 1, 2, 3, 4, 5 };  
var lastItem = array[^1];

It’s fine for .net. But on JAVA, I got the error:

“From End” operator requires an Index rtl type.

How can I use the ^, and … sytax when targeting JAVA?

Thanks.

Regards,  
Xiaoguang

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 7, 2022, 2:07pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/2 "2022-08-07T14:07:39Z")

</div>

> [@xiaoguang](#):
>
> I want to use the range index, and let the following codes complie fine when targeting JAVA:
> 
> var array = new int { 1, 2, 3, 4, 5 };  
> var lastItem = array[^1];
> 
> It’s fine for .net. But on JAVA, I got the error:
> 
> “From End” operator requires an Index rtl type.
> 
> How can I use the ^, and … sytax when targeting JAVA?

I believe this feature is specific to .NET, as it relies on runtime support by the class library. But I’ll log an issue to investigate iof we can provide support for it for the opther platforms, as well…

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [August 7, 2022, 2:08pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/3 "2022-08-07T14:08:13Z")

</div>

Logged as [bugs://E26075](https://www.remobjects.com/portal/bugs/?id=E26075).

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 7, 2022, 2:44pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/4 "2022-08-07T14:44:35Z")

</div>

Done (and works) for Java and Toffee

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [August 7, 2022, 3:20pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/5 "2022-08-07T15:20:13Z")

</div>

Excellent! Very glad to hear that.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 7, 2022, 5:47pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/6 "2022-08-07T17:47:41Z")

</div>

I’ve put a new build into your Personal Downloads. Let me know how it goes! 🤞🏼

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [August 8, 2022, 3:35pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/7 "2022-08-08T15:35:25Z")

</div>

Hello, the following codes are now complie fine on both .net and JAVA

var array = new int { 1, 2, 3, 4, 5 };  
var lastItem = array[^1];

But the following codes are not complie fine on either .net or JAVA.

var testStr = “abcdefg”;  
var str1 = testStr[..1];  
var str2 = testStr[1..];  
var str3 = testStr[^1..];  
var str4 = testStr[..^1];  
var str5 = testStr[1..6];

on .net:

 ![图片](https://talk.remobjects.com/uploads/default/original/3X/e/9/e9bf9bf411b39498a454f8461a053b571de3c4e8.png)  
// The chinese words means “object reference is not set to object instance”

on JAVA:

 ![图片](https://talk.remobjects.com/uploads/default/original/3X/b/f/bfc17edf261d36a58712cdd15a2578c140fa26eb.png)

Behaviour in visual C#:

 ![图片](https://talk.remobjects.com/uploads/default/original/3X/a/b/ab7196b273a95e66eab6aa80c97e984394054224.png)

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 8, 2022, 4:08pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/8 "2022-08-08T16:08:24Z")

</div>

> [@xiaoguang](#):
>
> Hello, the following codes are now complie fine on both .net and JAVA
> 
> var array = new int { 1, 2, 3, 4, 5 };  
> var lastItem = array[^1];

Yeah,

that’s the only code I tested.

> [@xiaoguang](#):
>
> on .net:

Hmm. That sounds like a compiler bug. reproduced; will log.

> [@xiaoguang](#):
>
> on JAVA:

This might be as designed, if java.String does not provide an indexer property that accepts a Range?

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [August 8, 2022, 4:10pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/9 "2022-08-08T16:10:14Z")

</div>

Logged as [bugs://E26076](https://www.remobjects.com/portal/bugs/?id=E26076).

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 8, 2022, 4:10pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/10 "2022-08-08T16:10:36Z")

</div>

Unfortunately this one will have to wait until next week, probalby.

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [August 8, 2022, 4:46pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/11 "2022-08-08T16:46:15Z")

</div>

I am not quite familiar with JAVA, so I am not sure. Just recently want to know something about the JAVA tech stack such as Gradle, and cross platform development. But the more I study, the more I like .Net:)

But var str1 = testStr[…1]; should work on .Net since it’s C# 8 sytax.

“Unfortunately this one will have to wait until next week, probalby”, no problem, it’s not urgent for me.

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [August 8, 2022, 4:49pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/12 "2022-08-08T16:49:43Z")

</div>

Another issue I found on this forum is:

When paste the codes, looks like 2 full stop will become 3 full stop, such as var str1 = testStr[…1]

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 8, 2022, 4:54pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/13 "2022-08-08T16:54:31Z")

</div>

> [@xiaoguang](#):
>
> But var str1 = testStr[…1]; should work on .Net since it’s C# 8 sytax.

Yes, this one is a compiler bug. Any “Internal Error” is.

> [@xiaoguang](#):
>
> “Unfortunately this one will have to wait until next week, probalby”, no problem, it’s not urgent for me.

Ok, cool.

> [@xiaoguang](#):
>
> When paste the codes, looks like 2 full stop will become 3 full stop, such as var str1 = testStr[…1]

yeah, I noticed that too. it seems any set of two or more dots gets turned into a single ellipsis character. Strange. That’s why its always good to close code snippets in back ticks (for a single line) or start./end code blocks with three backticks

`var str1 = testStr[........1];`  
var str1 = testStr[…1];

```auto
code
code code

```

 ![image](https://talk.remobjects.com/uploads/default/original/3X/8/0/803787704d5da6bf09abdb6ecb188acfb681cb67.png)

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [August 15, 2022, 6:52pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/14 "2022-08-15T18:52:49Z")

</div>

[bugs://E26075](https://www.remobjects.com/portal/bugs/?id=E26075) was closed as fixed.

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [September 16, 2022, 4:49pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/15 "2022-09-16T16:49:15Z")

</div>

@mh Hi, any update on bug E26076?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 16, 2022, 7:39pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/16 "2022-09-16T19:39:01Z")

</div>

Still open, i’m afraid, along with another Index-related bug I logged myself. I’ll try to get this priority next week. 🤞🏼

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [September 17, 2022, 4:49pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/17 "2022-09-17T16:49:07Z")

</div>

OK, thanks, that’s great!

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 19, 2022, 12:11pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/18 "2022-09-19T12:11:42Z")

</div>

> [@xiaoguang](#):
>
> @mh Hi, any update on bug E26076?

Do you actually still see this IE? i now get a new error (logged as separate issue) with your testcase:

```auto
			var str1 = testStr[..1]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
			var str2 = testStr[1..]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
			var str3 = testStr[^1..]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
			var str4 = testStr[..^1]; // E486 Parameter 1 is "<error>", should be "Int32", in call to Char String.get Chars(Int32 index)
			var str5 = testStr[1..6]; // E486 Parameter 1 is "Range", should be "Int32", in call to Char String.get Chars(Int32 index)

```

this one is being tracked as bugs://E26124: C# Range operator doesn’t work as advertised, and seems to be a combination of two slightly unrelated bugs:

(a) the `..` C# _language_ syntax just doesn’t seem to be handled correctly, for open-ended ranges  
(b).NET doesn’t have explicit overlords that take a Range, but expects the compiler to map those under the hood back to normal index-based calls. this isn’t happening (properly).

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [September 19, 2022, 12:57pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/19 "2022-09-19T12:57:06Z")

</div>

Hi,

On my computer with Element 2773:

 ![图片](https://talk.remobjects.com/uploads/default/original/3X/d/0/d09e3c9b6a9875001e6e547f3fb102e4ba98858b.png)

 ![图片](https://talk.remobjects.com/uploads/default/original/3X/1/9/1955796cedbe0ead3e00e07a2f746a9b939966bc.png)

I think C# language treats like this:

..1 // From the begining but dont’t take the index 1 element, so just take the index 0 element  
1.. // Take the index 1 element and the rest  
^1.. // This one is specail. The counting is from 1. ^1 mean the last element, and because no element after it, so only output the last element.  
..^1 // output all except the last element  
1..6 // output the 1 to 5 elements

But what does the magic the complier did, I have no idea.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 19, 2022, 1:09pm UTC](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057/20 "2022-09-19T13:09:11Z")

</div>

> [@xiaoguang](#):
>
> On my computer with Element 2773:

Good. that matches what I have.

[Next page](https://talk.remobjects.com/t/how-to-use-index-rtl-type/27057.md?page=2)
