Missing Return and Float should be Int

I have the codeblock like this and I am trying to get rid of the Float should be Int and Missing Return errors.

  package com.bykd.dev;

    @:final class Version
    {

        public static inline var SPLIT_CHAR : String = ".";

        public static var revisionKeyword : String = "Revision"; 

        private var _tag : String;

        private var _numbers : Array<Dynamic>;



public static function create(pfx:String, rev:String = null, sfx:String = null) : Version
		{
			var nums:Array = null;
			nums = pfx.split(SPLIT_CHAR);
			if(rev != null)
			{
				nums.push(trimRevision(rev));
			}
			return new Version(nums,sfx);
		}
         private static function trimRevision(rev : String) : String
        {
            var beg : Float = Math.NaN;
            var end : Float = Math.NaN; 
            beg = Std.string("$" + revisionKeyword + ": ").length; 
            end = rev.lastIndexOf(" $");
            return rev.substring(beg, end);   
        } 
    }

Errors are in the last lines :

  end = rev.lastIndexOf(" $");
                return rev.substring(beg, end);  

Any help would be highly appreciated.

You declared beg and end as Float and then you feed them into a function that wants Int

Declare beg and end as Int and you will be golden. Something like this:

         private static function trimRevision(rev : String) : String
        {
            var beg : Int = Std.string("$" + revisionKeyword + ": ").length; 
            var end : Int = rev.lastIndexOf(" $");
            return rev.substring(beg, end); 
        }
1 Like

Thank you so much , exactly what I was expecting.