NamedMap to accept/convert integers?

Issue #20 closed
Ville Rantanen created an issue

With Record, it was convenient to

for ( i <- 1 to 3) {
     segment(i)=SegmentSeeded(in= ... )
}

do we have to use i.toString or could NamedMap auto-convert that itself?

Comments (5)

  1. Ville Rantanen reporter

    same goes for accessing NamedMaps

    val wanted_split=FolderSplit(wanted_proc(2).out2, N=3)
    
  2. Kristian Ovaska

    I can implement these as a convenience function for NamedMap.

    Previously, org.anduril.runtime implicitly converted all integers to strings (not only for Record), which is a bad idea in general for statically typed languages.

  3. Kristian Ovaska

    Integer functions are now there.

    But I was wondering if NamedMap is the correct data structure for your case. A map having integer keys 0, 1, ..., N-1 is called a sequence, and NamedSeq can be used. Map is needed if the keys are sparse and non-contiguous, like if you have keys 5, 620 and 7840 only.

  4. Log in to comment