In Golang, we can return more than one value from a function, but this feature is not unique to the programming language. Other languages can do this too. Golang Function Declaration To Return Multiple Values Golang’s ability to return multiple
Golang – Read Text File Line by Line With The Bufio Package
This post shows how Golang can read a text file line by line using a buffered IO or bufio package. The content of a file may be in Chinese or English because Golang supports UTF-8 by default. Moreover, we do
Golang – Write Text to File Line by Line Using Buffered IO
Writing text to a file is a familiar use case that we may need to implement for our applications. Like most programming languages, Golang has facilities to enable us to implement such write text to files. This post briefly shows
Rust Owned And Borrowed Types
What are Owned and Borrowed types in Rust? To know these concepts, we need to understand first what Rust Ownership and Rust References. Get Your Head Around Rust Ownership When we talk about ownership in Rust, we generally mean –
What Are References In Rust And How To Use Them?
Understanding what references are in Rust and how to use them is crucial. A reference is a pointer to a memory location. A location where the data we’re interested in reside. A Rust reference is similar to the traditional pointers
Ways To Use Stack in Rust
There are several ways to implement or use a stack in Rust. A stack is a data structure that allows us to store data in LIFO (last-in-first-out). Rust has no stack data structure, but it offers data structures with similar
Rust – How to Compare Struct Instances With Traits
In Rust, we can compare if two struct instances are equivalent and whose respective field values are the same. However, doing so requires using traits. Equivalent vs. Partial Equivalent Before we proceed, let us differentiate between Equivalent and Partial Equivalent.
How To Concatenate Strings in Rust
We can concatenate Strings in any programming language, including Rust, and we do it a lot. No programming language does not deal with string concatenation. However, Rust is different as it has two types of strings – String and str.
Difference Between String and str in Rust
Rust has two (type of) string values – String and str. The difference between them is huge because Rust ships with functions that cater to both string types. Rust String and str Rust String is a dynamic string type from the
Mock Method To Return Different Values in Mockito
This post shows how to mock a method that returns unique values for different arguments in Mockito. For example, the return values vary according to the method argument. Sample Codes To Mock Suppose we have the following Java classes. The