This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package KotlinSrc | |
import java.util.* | |
import kotlin.reflect.KCallable | |
import kotlin.reflect.KType | |
import kotlin.reflect.full.createType | |
abstract class BaseRandom { | |
private val getNextByType: HashMap<KType, KCallable<*>> = HashMap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package JavaSrc; | |
import java.lang.reflect.InvocationTargetException; | |
import java.util.HashMap; | |
import java.util.Random; | |
import java.lang.reflect.Method; | |
public abstract class BaseRandom { | |
private int toInt(boolean bool) { return bool ? 1 : 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class BaseRandom: # Float\double takes way way too long lol just use random.random() [0, 1] | |
def __init__(self, rand: random.Random=None): | |
self.__next_by_type = { | |
"b": self.__nextbyte, | |
"s": self.__nextshort, | |
"i": self.__nextint, | |
"l": self.__nextlong, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigInteger | |
import kotlin.IndexOutOfBoundsException | |
data class BitFieldInfo(val fieldName: String, val fieldSize: Int, val fieldValue: BigInteger=0.bi) { | |
init { | |
if (fieldValue.bitLength() > fieldSize) throw IndexOutOfBoundsException("$fieldValue (${fieldValue.bitLength()} bits) too big to fit in $fieldSize bits") | |
if (fieldValue < 0.bi) throw NotImplementedError("Signed numbers are not yet implemented for BitFields") | |
if (fieldSize < 1) throw IndexOutOfBoundsException("Can't have a negative amount of bits ($fieldName, $fieldSize)") | |
} | |
constructor(fieldName: String, fieldSize: Int, fieldValue: Byte): this(fieldName, fieldSize, fieldValue.toInt()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val changelog20181122 = TEXTBOX { | |
+"Changes to Tags and TagBuilders" | |
+listTag { | |
+listItem("No more specifying when to use newlines. Newlines are now ALWAYS added BEFORE a string (+\"string\") when using builder syntax. I decided to go with this rather than explicitly specifying automatic newlines because it honestly makes more visual sense.") | |
+listItem("Because of the above change, NewlineIdentifier class (the gay ass bool wrapper) has been removed") | |
+listItem("One-liner tags are easier to create. Now you would use something like "+italicText("listItem(\"http://www.google.com\")")+" rather than "+ italicText("listItem { -newlineBefore; -newlineAfter; +\"http://www.google.com/\" }")) | |
+listItem("The above change was enabled by adding an initialization parameter to FullTagBuilder as well as adding a few .invoke constructors to TypedTag") | |
+listItem("Fixed a bug with FullTag.toString(String) putting the given string in both the tag AND making it the tagged text. oops |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String nullableString; | |
nullableString = "not null"; | |
nullableString = null; // this is fine :) | |
System.out.println(nullableString); // working as expected! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nullableString: String? | |
nullableString = "not null" | |
nullableString = null | |
println(nullableString) // prints null as expected, wow! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nullableString: String | |
nullableString = "not null" | |
nullableString = null // wait, the compiler no longer likes this. no compile for you! | |
println(nullableString) // we don't even get a chance to try! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public final class MaybeNull { | |
public static String maybeNullString() { | |
boolean isStringNull = new Random().nextBoolean(); | |
return isStringNull ? null : "not null"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val maybeNull: String = MaybeNull.maybeNullString() // allowed because compiler will assume you know what's happening with the `String!` | |
println(maybeNull) | |
} |
OlderNewer