mirror of
				https://github.com/InsanusMokrassar/MicroUtils.git
				synced 2025-11-04 06:00:22 +00:00 
			
		
		
		
	fixes
This commit is contained in:
		@@ -44,7 +44,7 @@ inline fun <T1, T2> Either.Companion.first(t1: T1): Either<T1, T2> = EitherFirst
 | 
			
		||||
/**
 | 
			
		||||
 * @return New instance of [EitherSecond]
 | 
			
		||||
 */
 | 
			
		||||
inline fun <T1, T2> Either.Companion.second(t1: T1): Either<T1, T2> = EitherFirst(t1)
 | 
			
		||||
inline fun <T1, T2> Either.Companion.second(t2: T2): Either<T1, T2> = EitherSecond(t2)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Will call [block] in case when [Either.t1] of [this] is not null
 | 
			
		||||
@@ -63,3 +63,9 @@ inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(crossinline block: (T2) -> Un
 | 
			
		||||
    t2 ?.let(block)
 | 
			
		||||
    return this
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline fun <reified T1, reified T2> Any.either() = when (this) {
 | 
			
		||||
    is T1 -> Either.first<T1, T2>(this)
 | 
			
		||||
    is T2 -> Either.second<T1, T2>(this)
 | 
			
		||||
    else -> error("Incorrect type of either argument $this")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user