<commit_before>package main

import "strings"

func initRArray() *RObject {
	obj := &RObject{}
	obj.name = "RArray"
	obj.ivars = make(map[string]Object)
	obj.class = nil
	obj.methods = make(map[string]*RMethod)

	// RArray method initialization
	obj.methods["new"] = &RMethod{gofunc: RArray_new}
	obj.methods["<<"] = &RMethod{gofunc: RArray_append}
	obj.methods["[]"] = &RMethod{gofunc: RArray_at}
	obj.methods["[]="] = &RMethod{gofunc: RArray_assign_to_index}
	obj.methods["to_s"] = &RMethod{gofunc: RArray_to_s}
	obj.methods["size"] = &RMethod{gofunc: RArray_length}
	obj.methods["length"] = &RMethod{gofunc: RArray_length}

	return obj
}

func RArray_new(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := &RObject{}
	obj.class = vm.consts["RArray"]
	obj.ivars = make(map[string]Object)
	obj.ivars["array"] = make([]*RObject, 0, 1024)

	if v != nil && len(v) > 0 {
		for _, item := range v {
			dummy_item := make([]Object, 1, 1)
			dummy_item[0] = item
			RArray_append(vm, obj, dummy_item)
		}
	}

	return obj
}

// array << obj
// [*RObject]
func RArray_append(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	obj.ivars["array"] = append(internal_array, v[0].(*RObject))

	return obj
}

func RArray_at(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	idx := v[0].(*RObject).val.fixnum

	return internal_array[idx]
}

func RArray_assign_to_index(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	idx := v[0].(*RObject).val.fixnum
	val := v[1].(*RObject)

	internal_array[idx] = val
	obj.ivars["array"] = internal_array

	return val
}

func RArray_to_s(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)
	strList := make([]string, 0, len(internal_array))
	for _, item := range internal_array {
		strList = append(strList, item.methodLookup("to_s").gofunc(vm, item, v).(string))
	}

	return strings.Join(strList, "\n")
}

func RArray_length(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	length := make([]Object, 1, 1)
	length[0] = int64(len(internal_array))

	return RFixnum_new(vm, receiver, length)
}
<commit_msg>[RArray] inspect() implemented<commit_after>package main

import "strings"

func initRArray() *RObject {
	obj := &RObject{}
	obj.name = "RArray"
	obj.ivars = make(map[string]Object)
	obj.class = nil
	obj.methods = make(map[string]*RMethod)

	// RArray method initialization
	obj.methods["new"] = &RMethod{gofunc: RArray_new}
	obj.methods["<<"] = &RMethod{gofunc: RArray_append}
	obj.methods["[]"] = &RMethod{gofunc: RArray_at}
	obj.methods["[]="] = &RMethod{gofunc: RArray_assign_to_index}
	obj.methods["to_s"] = &RMethod{gofunc: RArray_to_s}
	obj.methods["inspect"] = &RMethod{gofunc: RArray_inspect}
	obj.methods["size"] = &RMethod{gofunc: RArray_length}
	obj.methods["length"] = &RMethod{gofunc: RArray_length}

	return obj
}

func RArray_new(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := &RObject{}
	obj.class = vm.consts["RArray"]
	obj.ivars = make(map[string]Object)
	obj.ivars["array"] = make([]*RObject, 0, 1024)

	if v != nil && len(v) > 0 {
		for _, item := range v {
			dummy_item := make([]Object, 1, 1)
			dummy_item[0] = item
			RArray_append(vm, obj, dummy_item)
		}
	}

	return obj
}

// array << obj
// [*RObject]
func RArray_append(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	obj.ivars["array"] = append(internal_array, v[0].(*RObject))

	return obj
}

func RArray_at(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	idx := v[0].(*RObject).val.fixnum

	return internal_array[idx]
}

func RArray_assign_to_index(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	idx := v[0].(*RObject).val.fixnum
	val := v[1].(*RObject)

	internal_array[idx] = val
	obj.ivars["array"] = internal_array

	return val
}

func RArray_to_s(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)
	strList := make([]string, 0, len(internal_array))
	for _, item := range internal_array {
		strList = append(strList, item.methodLookup("to_s").gofunc(vm, item, v).(string))
	}

	return strings.Join(strList, "\n")
}

func RArray_inspect(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)
	strList := make([]string, 0, len(internal_array))
	for _, item := range internal_array {
		strList = append(strList, item.methodLookup("to_s").gofunc(vm, item, v).(string))
	}

	dummyList := []string{"[", strList[0]}
	strList[0] = strings.Join(dummyList, "")
	dummyList = []string{strList[len(strList)-1], "]"}
	strList[len(strList)-1] = strings.Join(dummyList, "")

	return strings.Join(strList, ", ")
}

func RArray_length(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	internal_array := obj.ivars["array"].([]*RObject)

	length := make([]Object, 1, 1)
	length[0] = int64(len(internal_array))

	return RFixnum_new(vm, receiver, length)
}

{'fraction_non_alphanumeric': 0.18356263577118032, 'fraction_numerical': 0.0077842143374366405, 'mean_word_length': 5.307077625570776, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5471688', 'n_tokens_mistral': 2166, 'n_tokens_neox': 2088, 'n_words': 419}