Rewriting simple C# nested class
        Posted  
        
            by Daniel
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Daniel
        
        
        
        Published on 2010-05-19T20:55:57Z
        Indexed on 
            2010/05/19
            21:00 UTC
        
        
        Read the original article
        Hit count: 214
        
F#
What would be an elegant way to implement the functionality of this nested class in F#?
  private class Aliaser {
     private int _count;
     internal Aliaser() { }
     internal string GetNextAlias() {
        return "t" + (_count++).ToString();
     }
  }
This was my first attempt, but it feels like there should be a sexy one-liner for this:
let aliases = (Seq.initInfinite (sprintf "t%d")).GetEnumerator()
let getNextAlias() = 
    aliases.MoveNext() |> ignore
    aliases.Current
© Stack Overflow or respective owner