Hello world

in #programming3 years ago

Hi everyone,

A few days ago, I received a strange message on Twitter that reminded my that I own a Steem account.

Luckily, I still got my steem key even if I never really used it in three years.

The idea behind Steem is as cool as it was the day I subscribed so I decided to give it a try, and will try to post a few dev posts.

English is not my main language and I will certainly do a few mistakes, so please, feel free to fix my poor english, a good developer always value a good feedback ;)

Currently I am trying to learn Golang, so for my first day, I want to share my solution to the hamming distance exercise from exercism I did today.

// Package hamming provides methods for hamming distance
package hamming
  
import "errors"
  
// Distance returns the Hamming Distance between two DNA strands.
func Distance(a, b string) (int, error) {
    if len(a) != len(b) {
        return -1, errors.New("DNA strands have different size")
    }
  
    distance := 0
    for i := range a {
        if b[i] != a[i] {
            distance++
        }
    }
  
    return distance, nil
}

I’m not really a huge fan of comments in code, I prefer a method with a meaningful name rather than having to put a comment to describe the method, but golint complains if I don't put comments for methods and packages.

Also I wasn’t sure about the error return in the first place.

I’ve also checked some other participants solutions, and found out some people are using runes. Don’t know what it is yet (is it an hashtable?) but looks pretty cool, I must check this out.

Sort:  

@tipy, thank you for supporting the HiveBuzz project by voting for our witness.

Here Is a small present to show our gratitude
Click on the badge to view your Board of Honor.

Once again, thanks for your support!

Hey @tipy from where are you learning GoLang. Are you into blockchain development...

Hey! Like I said, I'm using exercise.io to learn go.
I'm not really into blockchain development but maybe at some point I'll give it a try :)

ok, If you do come into blockchain, create blogs related to it.........

ok, If you do come into blockchain, create blogs related to it.........