pkt1583 / functionaljava

Automatically exported from code.google.com/p/functionaljava
0 stars 0 forks source link

ClassCastException converting string array to long array #28

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Is there a way to convert an array of String to an array of Long using map. 
Here it is a unit test to reproduce the issue.

@Test
public void strArrayToLongArray() {
   final Array<String> arrayStr = array("1", "2", "3");
   final Long[] arrayExp = new Long[]{new Long(1), new Long(2), new Long(3)};
   final Array<Long> arrayLong = arrayStr.map(new F<String, Long>() {
      @Override
      public Long f(final String s) {
         return Long.parseLong(s);
      }
   });

   final Long[] arrayAct = arrayLong.array();

   assertEquals(arrayExp, arrayAct);
}

Thanks, 
   Giacomo.

Original issue reported on code.google.com by gboccard on 23 Aug 2010 at 8:38

GoogleCodeExporter commented 9 years ago
It's an issue in the latest release available via Maven (2.19), but it's 
resolved in the current one (3.0).
So, you can mark this ticket as resolved.

Cheers,
   Giacomo.

Original comment by gboccard on 6 Oct 2010 at 11:12